12#include <libnova/julian_day.h>
18namespace AlignmentSubsystem
24 JulianDate - ln_get_julian_from_sys(), ApparentTelescopeDirectionVector);
28 double &RightAscension,
double &Declination,
double JulianDate)
31 JulianDate - ln_get_julian_from_sys());
48 static constexpr double kPolarThresholdDeg = 88.0;
51 static constexpr double kTargetPitchDeg = 80.0;
59 for (
auto &entry : db)
61 if (mountAlignment ==
ZENITH)
64 double sinThresh = std::sin(
DEG_TO_RAD(kPolarThresholdDeg));
65 if (std::abs(entry.TelescopeDirection.z) < sinThresh)
68 if (!haveLoc)
continue;
70 double currentPitchDeg =
RAD_TO_DEG(std::asin(entry.TelescopeDirection.z));
71 double targetPitch = (currentPitchDeg >= 0) ? kTargetPitchDeg : -kTargetPitchDeg;
72 double deltaDeg = currentPitchDeg - targetPitch;
77 entry.ObservationJulianDate, &hor);
79 double newEl = hor.
altitude - deltaDeg;
80 if (newEl < 20.0) newEl = 20.0;
81 if (newEl > kPolarThresholdDeg) newEl = kPolarThresholdDeg;
85 entry.Declination -= (hor.
altitude - newEl);
91 if (std::abs(entry.Declination) < kPolarThresholdDeg)
94 double encoderPitchDeg =
RAD_TO_DEG(std::asin(entry.TelescopeDirection.z));
95 double celDec = entry.Declination;
96 double targetCelDec = (celDec >= 0) ? kTargetPitchDeg : -kTargetPitchDeg;
97 double deltaDeg = celDec - targetCelDec;
100 double newEncoderPitch = encoderPitchDeg - deltaDeg;
107 entry.Declination = targetCelDec;
This class provides the driver side API to the in memory alignment database.
AlignmentDatabaseType & GetAlignmentDatabase()
Get a reference to the in memory database.
bool GetDatabaseReferencePosition(IGeographicCoordinates &Position)
Get the database reference position.
virtual bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset, TelescopeDirectionVector &ApparentTelescopeDirectionVector)=0
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
InMemoryDatabase * pInMemoryDatabase
virtual bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
virtual bool TransformTelescopeToCelestialJD(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianDate)
Get the true celestial coordinates for the supplied telescope pointing direction.
static void SanitizePolarEntries(InMemoryDatabase *pInMemoryDatabase, MountAlignment_t mountAlignment)
Sanitize alignment database entries that are near the pole (EQ) or zenith (altaz)....
virtual bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianOffset=0)=0
Get the true celestial coordinates for the supplied telescope pointing direction.
MountAlignment_t ApproximateMountAlignment
Describe the approximate alignment of the mount. This information is normally used in a one star alig...
virtual bool TransformCelestialToTelescopeJD(double RightAscension, double Declination, double JulianDate, TelescopeDirectionVector &ApparentTelescopeDirectionVector)
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
These functions are used to convert different coordinate systems to and from the telescope direction ...
const TelescopeDirectionVector TelescopeDirectionVectorFromAltitudeAzimuth(INDI::IHorizontalCoordinates HorizontalCoordinates)
Calculates a normalised direction vector from the supplied altitude and azimuth.
const TelescopeDirectionVector TelescopeDirectionVectorFromEquatorialCoordinates(INDI::IEquatorialCoordinates EquatorialCoordinates)
Calculates a telescope direction vector from the supplied equatorial coordinates.
Implementations for common driver routines.
enum INDI::AlignmentSubsystem::MountAlignment MountAlignment_t
Namespace to encapsulate INDI client, drivers, and mediator classes.
void EquatorialToHorizontal(IEquatorialCoordinates *object, IGeographicCoordinates *observer, double JD, IHorizontalCoordinates *position)
EquatorialToHorizontal Calculate horizontal coordinates from equatorial coordinates.
Holds a normalised direction vector (direction cosines)