11 namespace AlignmentSubsystem
15 void BuiltInMathPlugin::CalculateTransformMatrices(
const TelescopeDirectionVector &Alpha1,
16 const TelescopeDirectionVector &Alpha2,
17 const TelescopeDirectionVector &Alpha3,
18 const TelescopeDirectionVector &Beta1,
19 const TelescopeDirectionVector &Beta2,
20 const TelescopeDirectionVector &Beta3, gsl_matrix *pAlphaToBeta,
21 gsl_matrix *pBetaToAlpha)
24 gsl_matrix *pAlphaMatrix = gsl_matrix_alloc(3, 3);
25 gsl_matrix_set(pAlphaMatrix, 0, 0, Alpha1.x);
26 gsl_matrix_set(pAlphaMatrix, 1, 0, Alpha1.y);
27 gsl_matrix_set(pAlphaMatrix, 2, 0, Alpha1.z);
28 gsl_matrix_set(pAlphaMatrix, 0, 1, Alpha2.x);
29 gsl_matrix_set(pAlphaMatrix, 1, 1, Alpha2.y);
30 gsl_matrix_set(pAlphaMatrix, 2, 1, Alpha2.z);
31 gsl_matrix_set(pAlphaMatrix, 0, 2, Alpha3.x);
32 gsl_matrix_set(pAlphaMatrix, 1, 2, Alpha3.y);
33 gsl_matrix_set(pAlphaMatrix, 2, 2, Alpha3.z);
35 Dump3x3(
"AlphaMatrix", pAlphaMatrix);
37 gsl_matrix *pBetaMatrix = gsl_matrix_alloc(3, 3);
38 gsl_matrix_set(pBetaMatrix, 0, 0, Beta1.x);
39 gsl_matrix_set(pBetaMatrix, 1, 0, Beta1.y);
40 gsl_matrix_set(pBetaMatrix, 2, 0, Beta1.z);
41 gsl_matrix_set(pBetaMatrix, 0, 1, Beta2.x);
42 gsl_matrix_set(pBetaMatrix, 1, 1, Beta2.y);
43 gsl_matrix_set(pBetaMatrix, 2, 1, Beta2.z);
44 gsl_matrix_set(pBetaMatrix, 0, 2, Beta3.x);
45 gsl_matrix_set(pBetaMatrix, 1, 2, Beta3.y);
46 gsl_matrix_set(pBetaMatrix, 2, 2, Beta3.z);
48 Dump3x3(
"BetaMatrix", pBetaMatrix);
52 gsl_matrix *pInvertedAlphaMatrix = gsl_matrix_alloc(3, 3);
59 gsl_matrix_set_identity(pInvertedAlphaMatrix);
60 ASSDEBUG(
"CalculateTransformMatrices - Alpha matrix is singular!");
61 IDMessage(
nullptr,
"Alpha matrix is singular and cannot be inverted.");
67 Dump3x3(
"AlphaToBeta", pAlphaToBeta);
69 if (
nullptr != pBetaToAlpha)
77 gsl_matrix_set_identity(pBetaToAlpha);
78 ASSDEBUG(
"CalculateTransformMatrices - AlphaToBeta matrix is singular!");
81 "Calculated Celestial to Telescope transformation matrix is singular (not a true transform).");
84 Dump3x3(
"BetaToAlpha", pBetaToAlpha);
89 gsl_matrix_free(pInvertedAlphaMatrix);
90 gsl_matrix_free(pBetaMatrix);
91 gsl_matrix_free(pAlphaMatrix);
bool MatrixInvert3x3(gsl_matrix *pInput, gsl_matrix *pInversion)
Calculate the inverse of the supplied matrix.
void MatrixMatrixMultiply(gsl_matrix *pA, gsl_matrix *pB, gsl_matrix *pC)
Multiply matrix A by matrix B and put the result in C.
void Dump3x3(const char *Label, gsl_matrix *pMatrix)
Print out a 3x3 matrix to debug.
void IDMessage(const char *dev, const char *fmt,...)
Namespace to encapsulate INDI client, drivers, and mediator classes.