Instrument Neutral Distributed Interface INDI 2.2.5
SPKMathPlugin.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2026 Christian Kemper. All rights reserved.
3
4 SPK Math Plugin for INDI Alignment Subsystem.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9 .
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14 .
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*******************************************************************************/
20
21#pragma once
22
23#include "MathPlugin.h"
24#include "spk/spk.h"
26#include "libastro.h"
27
28namespace INDI
29{
30namespace AlignmentSubsystem
31{
32
34{
35 public:
37 virtual ~SPKMathPlugin();
38
39 virtual bool Initialise(InMemoryDatabase *pInMemoryDatabase) override;
40
41 virtual bool TransformCelestialToTelescopeJD(double RightAscension, double Declination,
42 double JulianDate,
43 TelescopeDirectionVector &ApparentTelescopeDirectionVector) override;
44
45 virtual bool TransformTelescopeToCelestialJD(const TelescopeDirectionVector &ApparentTelescopeDirectionVector,
46 double &RightAscension, double &Declination, double JulianDate) override;
47
48 virtual bool TransformCelestialToTelescope(const double RightAscension, const double Declination,
49 double JulianOffset,
50 TelescopeDirectionVector &ApparentTelescopeDirectionVector) override;
51
52 virtual bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector,
53 double &RightAscension, double &Declination, double JulianOffset = 0) override;
54
55 private:
56 spkOBS m_Obs;
57 spkPM m_PM;
58 spkAST m_Ast;
59 spkOPT m_Opt;
60 spkPO m_PO;
61
62 bool UpdateObsConfig();
63 void UpdateAstrometry(double JD);
64
65 std::vector<double> BuildObservationData(const InMemoryDatabase::AlignmentDatabaseType &syncPoints, int &outTermCount);
66 void ParsePmfitCoefficients(const double pmv[6], int terms);
67 TelescopeDirectionVector RollPitchToDirectionVector(double roll, double pitch);
68 void DirectionVectorToRollPitch(const TelescopeDirectionVector &v, double &roll, double &pitch);
69
70 // Incremental normal-equation accumulation (hot path, active when nt=6)
71 bool ExtractObsRow(const AlignmentDatabaseEntry &point,
72 double &oblon, double &oblat,
73 double &rdem, double &pdem);
74 bool AccumulateObsRow(double oblon, double oblat, double rdem, double pdem);
75 bool SolveNormalEquations(double pmv[6]);
76
77 double m_LST_rad {0}; // local sidereal time, set by UpdateAstrometry
78
79 double m_NE_A[36]; // AᵀA accumulator, row-major 6×6
80 double m_NE_v[6]; // Aᵀb accumulator
81 int m_NE_n; // number of sync points accumulated
82 char m_NE_mountChar; // 'A' or 'E' at time of last build
83 bool m_NE_valid; // true when NE state matches m_PM and m_NE_n
84};
85
86} // namespace AlignmentSubsystem
87} // namespace INDI
This class provides the driver side API to the in memory alignment database.
std::vector< AlignmentDatabaseEntry > AlignmentDatabaseType
Provides alignment subsystem functions to INDI alignment math plugins.
Definition MathPlugin.h:31
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 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 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 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 Initialise(InMemoryDatabase *pInMemoryDatabase) override
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
These functions are used to convert different coordinate systems to and from the telescope direction ...
Namespace to encapsulate INDI client, drivers, and mediator classes.
Entry in the in memory alignment database.
Definition Common.h:152
Holds a normalised direction vector (direction cosines)
Definition Common.h:69
Definition spk.h:136
Definition spk.h:78
Definition spk.h:94
Definition spk.h:100
Definition spk.h:113