From 09c89f6242ecf2495f86140a3f53ef4678f8563b Mon Sep 17 00:00:00 2001 From: SudhakarKuma Date: Wed, 25 Oct 2017 15:53:45 +0530 Subject: Updated OSP-plugin --- src/Calibrate.cpp | 278 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100755 src/Calibrate.cpp (limited to 'src/Calibrate.cpp') diff --git a/src/Calibrate.cpp b/src/Calibrate.cpp new file mode 100755 index 0000000..5e3aedc --- /dev/null +++ b/src/Calibrate.cpp @@ -0,0 +1,278 @@ +/* +The MIT License (MIT) + +Copyright (c) 2012 Juan Ramón + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "Calibrate.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +Calibrate::Calibrate(){ + _t0 = 0; + _k = 1.002737908; // Constant.. Relationship between the solar time (M) and the sidereal time (S): (S = M * 1.002737908) + _isSetR1 = false; + _isSetR2 = false; + _isSetR3 = false; +} + +/* + * Calculates the inverse of the m[3x3] matrix and returns it in the second parameter. + */ +void Calibrate::_inv(double m[3][3], double res[3][3]){ + double idet; + + //Inverse of the determinant + idet = 1/( + (m[0][0]*m[1][1]*m[2][2]) + (m[0][1]*m[1][2]*m[2][0]) + (m[0][2]*m[1][0]*m[2][1]) + - (m[0][2]*m[1][1]*m[2][0]) - (m[0][1]*m[1][0]*m[2][2]) - (m[0][0]*m[1][2]*m[2][1]) + ); + + res[0][0] = ((m[1][1]*m[2][2]) - (m[2][1]*m[1][2]))*idet; + res[0][1] = ((m[2][1]*m[0][2]) - (m[0][1]*m[2][2]))*idet; + res[0][2] = ((m[0][1]*m[1][2]) - (m[1][1]*m[0][2]))*idet; + + res[1][0] = ((m[1][2]*m[2][0]) - (m[2][2]*m[1][0]))*idet; + res[1][1] = ((m[2][2]*m[0][0]) - (m[0][2]*m[2][0]))*idet; + res[1][2] = ((m[0][2]*m[1][0]) - (m[1][2]*m[0][0]))*idet; + + res[2][0] = ((m[1][0]*m[2][1]) - (m[2][0]*m[1][1]))*idet; + res[2][1] = ((m[2][0]*m[0][1]) - (m[0][0]*m[2][1]))*idet; + res[2][2] = ((m[0][0]*m[1][1]) - (m[1][0]*m[0][1]))*idet; +} + +/* + * Multiplies two matrices, m1[3x3] and m2[3x3], and returns the result in + * the third parameter. + */ +void Calibrate::_m_prod(double m1[3][3], double m2[3][3], double res[3][3]){ + for(int i=0; i<3; i++) + for(int j=0; j<3; j++){ + res[i][j] = 0.0; + for(int k=0; k<3; k++) //multiplying row by column + res[i][j] += m1[i][k] * m2[k][j]; + } +} + +/* + * Calculates the Vector cosines (EVC) from the equatorial coordinates (ar, dec, t). + */ +void Calibrate::_setEVC(double ar, double dec, double t, double* EVC){ + EVC[0] = cos(dec)*cos(ar - _k*(t-_t0)); + EVC[1] = cos(dec)*sin(ar - _k*(t-_t0)); + EVC[2] = sin(dec); + qDebug() << "ardec = ["<