40 angle = range(value * 15.0);
43 angle = range(value * 180.0 / M_PI);
50 return this->angle * M_PI / 180.0;
70 this->target = degrees;
76 this->target = hours * 15.0;
100 case AXIS_TRACK_RATE::SIDEREAL:
103 case AXIS_TRACK_RATE::SOLAR:
106 case AXIS_TRACK_RATE::LUNAR:
122 guideRateDegSec = (360.0 / 86400) * rate;
123 guideDuration = durationMs / 1000.0;
124 LOGF_DEBUG(
"%s StartGuide rate %f=>%f, dur %d =>%f",
axisName, rate, guideRateDegSec.
Degrees(), durationMs, guideDuration);
129 struct timeval currentTime
135 gettimeofday(¤tTime,
nullptr);
137 if (lastTime.tv_sec == 0 && lastTime.tv_usec == 0)
138 lastTime = currentTime;
141 double interval = currentTime.tv_sec - lastTime.tv_sec + (currentTime.tv_usec - lastTime.tv_usec) / 1e6;
142 lastTime = currentTime;
159 Angle trc = target - rotateCentre;
163 double fastChange = mcRates[4].
Degrees() * interval;
164 double slowChange = fastChange / 5;
167 if (delta < -fastChange)
169 change = -fastChange;
171 else if (delta < -slowChange)
173 change = -slowChange;
175 else if (delta > fastChange)
179 else if (delta > slowChange)
208 if (guideDuration > 0)
210 change = guideRateDegSec.
Degrees() * (guideDuration > interval ? interval : guideDuration);
211 guideDuration -= interval;
232 case MOUNT_TYPE::ALTAZ:
233 case MOUNT_TYPE::EQ_FORK:
234 seco = (
latitude >= 0) ? secondary : -secondary;
237 case MOUNT_TYPE::EQ_GEM:
238 seco = (
latitude >= 0) ? secondary : -secondary;
240 if (seco > 90 || seco < -90)
266 *apparentRa =
lst() - ha;
288 Angle instrumentHa, instrumentDec;
293 case MOUNT_TYPE::ALTAZ:
295 case MOUNT_TYPE::EQ_FORK:
296 *secondary = (
latitude >= 0) ? instrumentDec : -instrumentDec;
297 *primary = instrumentHa;
299 case MOUNT_TYPE::EQ_GEM:
300 *secondary = instrumentDec;
301 *primary = instrumentHa;
303 if (instrumentHa < flipHourAngle)
306 *primary +=
Angle(180);
307 *secondary =
Angle(180) - instrumentDec;
310 *secondary = -*secondary;
331 *observedHa = instrumentHa + IH;
332 *observedDec = instrumentDec + ID;
335 double cosDec = *observedDec < maxDec ? std::cos(observedDec->
radians()) : std::cos(maxDec.
radians());
336 double tanDec = *observedDec < maxDec ? std::tan(observedDec->
radians()) : std::tan(maxDec.
radians());
338 *observedHa += (CH / cosDec);
340 *observedHa += (NP * tanDec);
372 double tanDec = *instrumentDec < maxDec ? std::tan(instrumentDec->
radians()) : std::tan(maxDec.
radians());
373 *instrumentHa -= (NP * tanDec);
375 double cosDec = *instrumentDec < maxDec ? std::cos(instrumentDec->
radians()) : std::cos(maxDec.
radians());
376 *instrumentHa -= (CH / cosDec);
380 *instrumentDec -= ID;
385 Angle correctionHa, correctionDec;
386 correction(observedHa, observedDec, &correctionHa, &correctionDec);
388 *instrumentHa = observedHa - correctionHa;
389 *instrumentDec = observedDec - correctionDec;
391 static const Angle minDelta(1.0 / 3600.0);
399 correction(*instrumentHa, *instrumentDec, &correctionHa, &correctionDec);
400 newHa = *instrumentHa + correctionHa;
401 newDec = *instrumentDec + correctionDec;
403 dHa = observedHa - newHa;
404 dDec = observedDec - newDec;
413 *instrumentHa += dHa;
414 *instrumentDec += dDec;
423 void Alignment::correction(
Angle instrumentHa,
Angle instrumentDec,
Angle * correctionHa,
Angle * correctionDec)
430 static const double minCos = 0.01;
431 static const double maxTan = 100.0;
433 double cosDec = std::cos(instrumentDec.
radians());
434 if (cosDec >= 0 && cosDec < minCos) cosDec = minCos;
435 else if (cosDec <= 0 && cosDec > -minCos) cosDec = -minCos;
437 double tanDec = std::tan(instrumentDec.
radians());
438 if (tanDec > maxTan) tanDec = maxTan;
439 if (tanDec < -maxTan) tanDec = -maxTan;
441 double cosHa = std::cos(instrumentHa.
radians());
442 double sinHa = std::sin(instrumentHa.
radians());
445 *correctionHa += (CH / cosDec);
447 *correctionHa += (NP * tanDec);
450 *correctionHa += (-MA * cosHa * tanDec);
451 *correctionDec += (MA * sinHa);
454 *correctionHa += (ME * sinHa * tanDec);
455 *correctionDec += (ME * cosHa);
477 LOGF_DEBUG(
"setCorrections IH %f, ID %f, CH %f, NP %f, MA %f, ME %f", IH, ID, CH, NP, MA, ME);
486 double len = std::sqrt(x * x + y * y + z * z);
528 double ca = std::cos(angle.
radians());
529 double sa = std::sin(angle.
radians());
530 return Vector(
L,
M * ca +
N * sa,
N * ca -
M * sa);
535 double ca = std::cos(angle.
radians());
536 double sa = std::sin(angle.
radians());
537 return Vector(
L * ca -
N * sa,
M,
L * sa +
N * ca);
542 double ca = std::cos(angle.
radians());
543 double sa = std::sin(angle.
radians());
544 return Vector(
L * ca +
M * sa,
M * ca -
L * sa,
N);
void setCorrections(double ih, double id, double ch, double np, double ma, double me)
setCorrections set the values of the six corrections
void apparentRaDecToMount(Angle apparentRa, Angle apparentDec, Angle *primary, Angle *secondary)
void mountToApparentHaDec(Angle primary, Angle secondary, Angle *apparentHa, Angle *apparentDec)
mountToApparentHaDec: convert mount position to apparent Ha, Dec
void apparentHaDecToMount(Angle apparentHa, Angle apparentDec, Angle *primary, Angle *secondary)
apparentHaDecToMount
void observedToInstrument(Angle observedHa, Angle observedDec, Angle *instrumentHa, Angle *instrumentDec)
void mountToApparentRaDec(Angle primary, Angle secondary, Angle *apparentRa, Angle *apparentDec)
mountToApparentRaDec: convert mount position to apparent Ra, Dec
void instrumentToObserved(Angle instrumentHa, Angle instrumentDec, Angle *observedHa, Angle *observedDec)
The Angle class This class implements an angle type. This holds an angle that is always in the range ...
double Degrees360()
Degrees360.
double difference(Angle a)
bool operator==(const Angle &a)
bool operator!=(const Angle &a)
Angle TrackingRateDegSec
TrackingRateDegSec.
void setDegrees(double degrees)
void StartGuide(double rate, uint32_t durationMs)
StartGuide start guiding.
void Tracking(bool enabled)
AXIS_TRACK_RATE TrackRate()
TrackRate returns the AXIS_TRACK_RATE property.
void StartSlew(Angle angle)
AXIS_TRACK_RATE
The AXIS_TRACK_RATE enum defines the common track rates.
void setHours(double hours)
The Vector class This implements the Directional Cosine used by Taki in his Matrix method....
Vector rotateY(Angle angle)
rotateY rotates this vector through angle about the Y axis
Vector rotateX(Angle angle)
rotateX rotates this vector through angle about the X axis
Vector()
Vector creates an empty vector.
Vector rotateZ(Angle angle)
rotateZ rotates this vector through angle about the Z axis
Angle secondary()
secondary returns the secondary angle (dec, altitude) from this vector
Angle primary()
primary returns the primary angle (Ra, Ha, Azimuth) from this vector
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sideral time given longitude and system clock.
#define LOGF_DEBUG(fmt,...)
#define LOGF_EXTRA1(fmt,...)