23#include <libnova/julian_day.h>
27namespace AlignmentSubsystem
29#ifndef NO_PLUGIN_HOOKS
36 NearestMathPlugin *
Create()
38 return new NearestMathPlugin;
54 return "Nearest Math Plugin";
84 ExtendedAlignmentPoints.clear();
94 for (
auto &oneSyncPoint : SyncPoints)
126 ExtendedAlignmentPoints.push_back(oneEntry);
139 ln_get_julian_from_sys() + JulianOffset,
140 ApparentTelescopeDirectionVector);
158 if (ExtendedAlignmentPoints.empty())
223 double &RightAscension,
double &Declination,
double JulianOffset)
226 ln_get_julian_from_sys() + JulianOffset);
230 double &RightAscension,
double &Declination,
double JulianDate)
240 if (ExtendedAlignmentPoints.empty())
300 Declination = TransformedCelestialRADE.
declination;
311 double distance = 1e6;
313 for (
auto &oneEntry : ExtendedAlignmentPoints)
315 double oneDistance = 0;
318 oneDistance = SphereUnitDistance(Azimuth, oneEntry.CelestialAzimuth, Altitude, oneEntry.CelestialAltitude);
320 oneDistance = SphereUnitDistance(Azimuth, oneEntry.TelescopeAzimuth, Altitude, oneEntry.TelescopeAltitude);
322 if (oneDistance < distance)
325 distance = oneDistance;
335double NearestMathPlugin::SphereUnitDistance(
double theta1,
double theta2,
double phi1,
double phi2)
337 double sqrt_haversin_lat = sin(((phi2 - phi1) / 2) * (
M_PI / 180));
338 double sqrt_haversin_long = sin(((theta2 - theta1) / 2) * (
M_PI / 180));
340 asin(sqrt((sqrt_haversin_lat * sqrt_haversin_lat) + cos(phi1 * (
M_PI / 180)) * cos(phi2 * (
M_PI / 180)) *
341 (sqrt_haversin_long * sqrt_haversin_long))));
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.
InMemoryDatabase * pInMemoryDatabase
virtual bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
MountAlignment_t ApproximateMountAlignment
Describe the approximate alignment of the mount. This information is normally used in a one star alig...
virtual bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianOffset=0) override
Get the true celestial coordinates for the supplied telescope pointing direction.
virtual bool TransformCelestialToTelescopeJD(double RightAscension, double Declination, double JulianDate, TelescopeDirectionVector &ApparentTelescopeDirectionVector) override
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
virtual bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset, TelescopeDirectionVector &ApparentTelescopeDirectionVector) override
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
virtual bool TransformTelescopeToCelestialJD(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianDate) override
Get the true celestial coordinates for the supplied telescope pointing direction.
virtual ~NearestMathPlugin()
virtual bool Initialise(InMemoryDatabase *pInMemoryDatabase) override
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
const TelescopeDirectionVector TelescopeDirectionVectorFromAltitudeAzimuth(INDI::IHorizontalCoordinates HorizontalCoordinates)
Calculates a normalised direction vector from the supplied altitude and azimuth.
void EquatorialCoordinatesFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector, INDI::IEquatorialCoordinates &EquatorialCoordinates)
Calculates equatorial coordinates from the supplied telescope direction vector and declination.
const TelescopeDirectionVector TelescopeDirectionVectorFromEquatorialCoordinates(INDI::IEquatorialCoordinates EquatorialCoordinates)
Calculates a telescope direction vector from the supplied equatorial coordinates.
void AltitudeAzimuthFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector, INDI::IHorizontalCoordinates &HorizontalCoordinates)
Calculates an altitude and azimuth from the supplied normalised direction vector and declination.
void Destroy(DummyMathPlugin *pPlugin)
DummyMathPlugin * Create()
const char * GetDisplayName()
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.
void HorizontalToEquatorial(IHorizontalCoordinates *object, IGeographicCoordinates *observer, double JD, IEquatorialCoordinates *position)
HorizontalToEquatorial Calculate Equatorial EOD Coordinates from horizontal coordinates.
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
double ObservationJulianDate
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
double Declination
Declination in decimal degrees.
double CelestialAzimuth
Celestial Azimuth of Sync Point at the time it was added to the list.
double TelescopeAzimuth
Telescope Azimuth of Sync Point at the time it was added to the list.
double TelescopeAltitude
Telescope Altitude of the Sync point at the time it was added to the list.
double CelestialAltitude
Celestial Altitude of the Sync point at the time it was added to the list.
Holds a normalised direction vector (direction cosines)