General Purpose Geodetic Library
Sg3dMatrix.cpp
Go to the documentation of this file.
1
/*
2
*
3
* This file is a part of Space Geodetic Library. The library is used by
4
* nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5
* geodetic VLBI observations.
6
* Copyright (C) 2010-2020 Sergei Bolotin.
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
24
/*
25
*
26
* This file is part of General Purpose Geodetic Library
27
*
28
* Some copyright issues...
29
*
30
*/
31
32
33
#include <
Sg3dMatrix.h
>
34
35
// zero matrix:
36
const
Sg3dMatrix
m3Zero
37
(
38
Sg3dVector
(0.0, 0.0, 0.0),
39
Sg3dVector
(0.0, 0.0, 0.0),
40
Sg3dVector
(0.0, 0.0, 0.0)
41
);
42
43
// unit matrix:
44
const
Sg3dMatrix
m3E
45
(
46
Sg3dVector
(1.0, 0.0, 0.0),
47
Sg3dVector
(0.0, 1.0, 0.0),
48
Sg3dVector
(0.0, 0.0, 1.0)
49
);
50
51
52
53
/*=====================================================================================================*/
54
//
55
// Sg3dMatrix implementation
56
//
57
/*=====================================================================================================*/
58
Sg3dMatrix
operator*
(
const
Sg3dMatrix
& M1,
const
Sg3dMatrix
& M2)
59
{
60
Sg3dMatrix
M;
61
M.
mat
[0][0] = M1.
mat
[0][0]*M2.
mat
[0][0] + M1.
mat
[0][1]*M2.
mat
[1][0] + M1.
mat
[0][2]*M2.
mat
[2][0];
62
M.
mat
[0][1] = M1.
mat
[0][0]*M2.
mat
[0][1] + M1.
mat
[0][1]*M2.
mat
[1][1] + M1.
mat
[0][2]*M2.
mat
[2][1];
63
M.
mat
[0][2] = M1.
mat
[0][0]*M2.
mat
[0][2] + M1.
mat
[0][1]*M2.
mat
[1][2] + M1.
mat
[0][2]*M2.
mat
[2][2];
64
65
M.
mat
[1][0] = M1.
mat
[1][0]*M2.
mat
[0][0] + M1.
mat
[1][1]*M2.
mat
[1][0] + M1.
mat
[1][2]*M2.
mat
[2][0];
66
M.
mat
[1][1] = M1.
mat
[1][0]*M2.
mat
[0][1] + M1.
mat
[1][1]*M2.
mat
[1][1] + M1.
mat
[1][2]*M2.
mat
[2][1];
67
M.
mat
[1][2] = M1.
mat
[1][0]*M2.
mat
[0][2] + M1.
mat
[1][1]*M2.
mat
[1][2] + M1.
mat
[1][2]*M2.
mat
[2][2];
68
69
M.
mat
[2][0] = M1.
mat
[2][0]*M2.
mat
[0][0] + M1.
mat
[2][1]*M2.
mat
[1][0] + M1.
mat
[2][2]*M2.
mat
[2][0];
70
M.
mat
[2][1] = M1.
mat
[2][0]*M2.
mat
[0][1] + M1.
mat
[2][1]*M2.
mat
[1][1] + M1.
mat
[2][2]*M2.
mat
[2][1];
71
M.
mat
[2][2] = M1.
mat
[2][0]*M2.
mat
[0][2] + M1.
mat
[2][1]*M2.
mat
[1][2] + M1.
mat
[2][2]*M2.
mat
[2][2];
72
return
M;
73
};
74
/*=====================================================================================================*/
75
76
77
78
/*=====================================================================================================*/
79
//
80
// Sg3dMatrix's friends:
81
//
82
/*=====================================================================================================*/
83
Sg3dMatrix
operator~
(
const
Sg3dMatrix
& M1)
84
{
85
double
d(M1.
module
());
86
Sg3dMatrix
M;
87
88
M.
mat
[0][0] = (M1.
mat
[1][1]*M1.
mat
[2][2] - M1.
mat
[1][2]*M1.
mat
[2][1])/d;
89
M.
mat
[0][1] = (M1.
mat
[2][1]*M1.
mat
[0][2] - M1.
mat
[0][1]*M1.
mat
[2][2])/d;
90
M.
mat
[0][2] = (M1.
mat
[0][1]*M1.
mat
[1][2] - M1.
mat
[1][1]*M1.
mat
[0][2])/d;
91
92
M.
mat
[1][0] = (M1.
mat
[2][0]*M1.
mat
[1][2] - M1.
mat
[1][0]*M1.
mat
[2][2])/d;
93
M.
mat
[1][1] = (M1.
mat
[0][0]*M1.
mat
[2][2] - M1.
mat
[2][0]*M1.
mat
[0][2])/d;
94
M.
mat
[1][2] = (M1.
mat
[1][0]*M1.
mat
[0][2] - M1.
mat
[0][0]*M1.
mat
[1][2])/d;
95
96
M.
mat
[2][0] = (M1.
mat
[1][0]*M1.
mat
[2][1] - M1.
mat
[2][0]*M1.
mat
[1][1])/d;
97
M.
mat
[2][1] = (M1.
mat
[2][0]*M1.
mat
[0][1] - M1.
mat
[0][0]*M1.
mat
[2][1])/d;
98
M.
mat
[2][2] = (M1.
mat
[0][0]*M1.
mat
[1][1] - M1.
mat
[1][0]*M1.
mat
[0][1])/d;
99
return
M;
100
};
101
/*=====================================================================================================*/
operator*
Sg3dMatrix operator*(const Sg3dMatrix &M1, const Sg3dMatrix &M2)
Definition:
Sg3dMatrix.cpp:58
operator~
Sg3dMatrix operator~(const Sg3dMatrix &M1)
Definition:
Sg3dMatrix.cpp:83
m3Zero
const Sg3dMatrix m3Zero(Sg3dVector(0.0, 0.0, 0.0), Sg3dVector(0.0, 0.0, 0.0), Sg3dVector(0.0, 0.0, 0.0))
m3E
const Sg3dMatrix m3E(Sg3dVector(1.0, 0.0, 0.0), Sg3dVector(0.0, 1.0, 0.0), Sg3dVector(0.0, 0.0, 1.0))
Sg3dMatrix.h
Sg3dMatrix
Definition:
Sg3dMatrix.h:45
Sg3dMatrix::mat
double mat[3][3]
The 3x3 array that is storing elements of a matrix.
Definition:
Sg3dMatrix.h:47
Sg3dMatrix::module
double module() const
Definition:
Sg3dMatrix.h:253
Sg3dVector
Definition:
Sg3dVector.h:49
src
SgLib
Sg3dMatrix.cpp
Generated by
1.9.1