23 #include <libnova/julian_day.h>
27 namespace AlignmentSubsystem
35 NearestMathPlugin *
Create()
37 return new NearestMathPlugin;
53 return "Nearest Math Plugin";
82 ExtendedAlignmentPoints.clear();
92 for (
auto &oneSyncPoint : SyncPoints)
124 ExtendedAlignmentPoints.push_back(oneEntry);
140 double JDD = ln_get_julian_from_sys() + JulianOffset;
148 if (ExtendedAlignmentPoints.empty())
206 double &RightAscension,
double &Declination)
212 double JDD = ln_get_julian_from_sys();
218 if (ExtendedAlignmentPoints.empty())
278 Declination = TransformedCelestialRADE.
declination;
289 double distance = 1e6;
291 for (
auto &oneEntry : ExtendedAlignmentPoints)
293 double oneDistance = 0;
296 oneDistance = SphereUnitDistance(Azimuth, oneEntry.CelestialAzimuth, Altitude, oneEntry.CelestialAltitude);
298 oneDistance = SphereUnitDistance(Azimuth, oneEntry.TelescopeAzimuth, Altitude, oneEntry.TelescopeAltitude);
300 if (oneDistance < distance)
303 distance = oneDistance;
313 double NearestMathPlugin::SphereUnitDistance(
double theta1,
double theta2,
double phi1,
double phi2)
315 double sqrt_haversin_lat = sin(((phi2 - phi1) / 2) * (M_PI / 180));
316 double sqrt_haversin_long = sin(((theta2 - theta1) / 2) * (M_PI / 180));
318 asin(sqrt((sqrt_haversin_lat * sqrt_haversin_lat) + cos(phi1 * (M_PI / 180)) * cos(phi2 * (M_PI / 180)) *
319 (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.
std::vector< AlignmentDatabaseEntry > AlignmentDatabaseType
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 Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
virtual bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination)
Get the true celestial coordinates for the supplied telescope pointing direction.
virtual bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset, TelescopeDirectionVector &ApparentTelescopeDirectionVector)
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
virtual ~NearestMathPlugin()
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 nomalised direction vector (direction cosines)