42 angle = range(value * 15.0);
45 angle = range(value * 180.0 /
M_PI);
52 return this->angle *
M_PI / 180.0;
72 this->target = degrees;
78 this->target = hours * 15.0;
129 guideRateDegSec = (360.0 / 86400) * rate;
130 guideDuration = durationMs / 1000.0;
131 LOGF_DEBUG(
"%s StartGuide rate %f=>%f, dur %d =>%f",
axisName, rate, guideRateDegSec.
Degrees(), durationMs, guideDuration);
136 struct timeval currentTime
142 gettimeofday(¤tTime,
nullptr);
144 if (lastTime.tv_sec == 0 && lastTime.tv_usec == 0)
145 lastTime = currentTime;
148 double interval = currentTime.tv_sec - lastTime.tv_sec + (currentTime.tv_usec - lastTime.tv_usec) / 1e6;
149 lastTime = currentTime;
166 Angle trc = target - rotateCentre;
170 double fastChange = mcRates[4].
Degrees() * interval;
171 double slowChange = fastChange / 5;
174 if (delta < -fastChange)
176 change = -fastChange;
178 else if (delta < -slowChange)
180 change = -slowChange;
182 else if (delta > fastChange)
186 else if (delta > slowChange)
200 int rate = std::max(-4,std::min(4,
mcRate));
208 change = -mcRates[-rate].
Degrees() * interval;
214 change = mcRates[rate].
Degrees() * interval;
220 if (guideDuration > 0)
222 change = guideRateDegSec.
Degrees() * (guideDuration > interval ? interval : guideDuration);
223 guideDuration -= interval;
224 LOGF_DEBUG(
"guide rate %f, remaining duration %f, change %f", guideRateDegSec.
Degrees(), guideDuration, change);
251 seco = (
latitude >= 0) ? secondary : -secondary;
255 seco = (
latitude >= 0) ? secondary : -secondary;
257 if (seco > 90 || seco < -90)
261 prio = primary +
Angle(180.0);
262 seco =
Angle(180.0) - seco;
274 Vector trueAzAlt(*apparentHa -
Angle(180.0), *apparentDec);
292 *apparentRa =
lst() - ha;
311 *instrumentHa = haDec.
primary();
316 *instrumentDec = (
latitude >= 0) ? secondary : -secondary;
317 *instrumentHa = primary;
324 *instrumentHa = primary +
Angle(180.0);
325 *instrumentDec =
Angle(180.0) - seco;
329 *instrumentHa = primary;
330 *instrumentDec = seco;
354 *primary = instrumentHa;
355 *secondary = (
latitude >= 0) ? instrumentDec : -instrumentDec;
358 if (instrumentHa < flipHourAngle)
362 *primary = instrumentHa +
Angle(180);
363 *secondary =
Angle(180) - instrumentDec;
367 *primary = instrumentHa;
368 *secondary = instrumentDec;
371 *secondary = -*secondary;
389 Angle instrumentAz, instrumentAlt;
392 *primary = instrumentAz;
393 *secondary = instrumentAlt;
400 Angle instrumentHa, instrumentDec;
423 *observedHa = instrumentHa + IH;
424 *observedDec = instrumentDec + ID;
427 double cosDec = *observedDec < maxDec ? std::cos(observedDec->
radians()) : std::cos(maxDec.
radians());
428 double tanDec = *observedDec < maxDec ? std::tan(observedDec->
radians()) : std::tan(maxDec.
radians());
430 *observedHa += (CH / cosDec);
432 *observedHa += (NP * tanDec);
464 double tanDec = *instrumentDec < maxDec ? std::tan(instrumentDec->
radians()) : std::tan(maxDec.
radians());
465 *instrumentHa -= (NP * tanDec);
467 double cosDec = *instrumentDec < maxDec ? std::cos(instrumentDec->
radians()) : std::cos(maxDec.
radians());
468 *instrumentHa -= (CH / cosDec);
472 *instrumentDec -= ID;
477 Angle correctionHa, correctionDec;
478 correction(observedHa, observedDec, &correctionHa, &correctionDec);
480 *instrumentHa = observedHa - correctionHa;
481 *instrumentDec = observedDec - correctionDec;
483 static const Angle minDelta(1.0 / 3600.0);
491 correction(*instrumentHa, *instrumentDec, &correctionHa, &correctionDec);
492 newHa = *instrumentHa + correctionHa;
493 newDec = *instrumentDec + correctionDec;
495 dHa = observedHa - newHa;
496 dDec = observedDec - newDec;
505 *instrumentHa += dHa;
506 *instrumentDec += dDec;
515void Alignment::correction(
Angle instrumentHa,
Angle instrumentDec,
Angle * correctionHa,
Angle * correctionDec)
522 static const double minCos = 0.01;
523 static const double maxTan = 100.0;
525 double cosDec = std::cos(instrumentDec.
radians());
526 if (cosDec >= 0 && cosDec < minCos) cosDec = minCos;
527 else if (cosDec <= 0 && cosDec > -minCos) cosDec = -minCos;
529 double tanDec = std::tan(instrumentDec.
radians());
530 if (tanDec > maxTan) tanDec = maxTan;
531 if (tanDec < -maxTan) tanDec = -maxTan;
533 double cosHa = std::cos(instrumentHa.
radians());
534 double sinHa = std::sin(instrumentHa.
radians());
537 *correctionHa += (CH / cosDec);
539 *correctionHa += (NP * tanDec);
542 *correctionHa += (-MA * cosHa * tanDec);
543 *correctionDec += (MA * sinHa);
546 *correctionHa += (ME * sinHa * tanDec);
547 *correctionDec += (ME * cosHa);
569 LOGF_DEBUG(
"setCorrections IH %f, ID %f, CH %f, NP %f, MA %f, ME %f", IH, ID, CH, NP, MA, ME);
578 double len = std::sqrt(x * x + y * y + z * z);
620 double ca = std::cos(angle.
radians());
621 double sa = std::sin(angle.
radians());
622 return Vector(
L,
M * ca +
N * sa,
N * ca -
M * sa);
627 double ca = std::cos(angle.
radians());
628 double sa = std::sin(angle.
radians());
629 return Vector(
L * ca -
N * sa,
M,
L * sa +
N * ca);
634 double ca = std::cos(angle.
radians());
635 double sa = std::sin(angle.
radians());
636 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 instrumentHaDecToMount(Angle instrumentHa, Angle instrumentDec, Angle *primary, Angle *secondary)
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)
void mountToInstrumentHaDec(Angle primary, Angle secondary, Angle *instrumentHa, Angle *instrumentDec)
mountToInstrumentHaDec: convert mount axis positions to instrument (encoder) HA/Dec without applying ...
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)
double getTrackingRateDegSec()
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 sidereal time given longitude and system clock.
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
#define LOGF_EXTRA1(fmt,...)
char device_str[64]
The transformations are based on the paper "Matrix Method for Coordinates Transformation" written by ...