1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2013 Martin Brehm
6
2012-2013 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
28
void CxMatrix3::Dump() const
34
/* for (z2=0;z2<3;z2++)
35
if ((GetAt(z2,z) < 0) && (GetAt(z2,z) > -0.000000001))
37
mprintf("( %6.3f %6.3f %6.3f )\n",GetAt(0,z),GetAt(1,z),GetAt(2,z));
43
void CxMatrix3::MatUltra(const CxVector3 &vec1, const CxVector3 &vec2)
47
CxVector3 vectemp, vecx, vecy, vec2n, vectemp2;
48
/* float mat[3][3], mat2[3][3];
49
float vectemp[3], vecx[3], vecy[3], vec2n[3], vectemp2[3];*/
53
mprintf("\nLinAlg Checker\n\n");
54
mprintf("Vektor 1: "); vec1.Dump();
55
mprintf("\nVektor 2: "); vec2.Dump();
66
mprintf("\nVektor X: "); vecx.Dump();
67
mprintf("\nVektor Y: "); vecy.Dump();
70
// Zu erst vec1 auf X drehen
71
vectemp = CrossP(vec1,vecx);
72
if (vectemp.GetLength() != 0)
75
mprintf("\nDrehachse fuer Vektor1->X: ");
80
mprintf("\nNormalisiert: ");
85
mprintf("\nDrehwinkel: %.1f Grad\n",a*180.0/Pi);
87
mat.RotMat(vectemp,a);
91
mprintf("\nDer liegt schon auf der X-Achse!");
98
mprintf("Drehmatrix dafuer:\n"); mat.Dump();
100
mprintf("\nDamit wird Vektor1 zu "); vectemp.Dump();
101
mprintf("\nUnd Vektor2 zu "); vec2n.Dump();
104
if ((vec2-vec1).GetLength() < 0.0001) // vec1 == vec2, nichts in X-Y-Ebene drehen
112
vectemp2[1] = vec2n[1];
113
vectemp2[2] = vec2n[2];
115
#ifdef DEBUG_MATULTRA
116
mprintf("\nProjektion von Vektor2n auf YZ-Ebene: ");
120
a = Angle(vectemp2,vecy);
122
#ifdef DEBUG_MATULTRA
126
if (vectemp2.GetLength()==0)
128
eprintf("\nMatUltra: Error caught.\n");
135
#ifdef DEBUG_MATULTRA
136
mprintf("\nDrehachse fuer Vektor2->XY: ");
138
mprintf("\nDrehwinkel: %.1f Grad\n",a*180.0/Pi);
143
#ifdef DEBUG_MATULTRA
144
mprintf("Drehmatrix dafuer:\n"); mat2.Dump();
146
vectemp2 = mat2*vectemp;
147
mprintf("\nDamit wird Vektor1 zu "); vectemp2.Dump();
148
vectemp = mat2*vec2n;
149
mprintf("\nUnd Vektor2n zu "); vectemp.Dump();
154
#ifdef DEBUG_MATULTRA
155
mprintf("\nMacht diese Gesamtmatrix:\n"); Dump();
156
vectemp = *this*vec1;
157
mprintf("\nDamit wird Vektor 1 von "); vec1.Dump(); mprintf(" zu "); vectemp.Dump();
158
vectemp = *this*vec2;
159
mprintf("\nUnd Vektor 2 wird von "); vec2.Dump(); mprintf(" zu "); vectemp.Dump();
167
void CxMatrix3::Invert()
169
#define a11 GetAt(0,0)
170
#define a12 GetAt(0,1)
171
#define a13 GetAt(0,2)
172
#define a21 GetAt(1,0)
173
#define a22 GetAt(1,1)
174
#define a23 GetAt(1,2)
175
#define a31 GetAt(2,0)
176
#define a32 GetAt(2,1)
177
#define a33 GetAt(2,2)
182
det = a11 * (a33*a22 - a32*a23)
183
- a21 * (a33*a12 - a32*a13)
184
+ a31 * (a23*a12 - a22*a13);
188
eprintf("CxMatrix3::Invert(): Failed - matrix is singular.\n");
192
t.GetAt(0,0) = (a33*a22 - a32*a23);
193
t.GetAt(0,1) = -(a33*a12 - a32*a13);
194
t.GetAt(0,2) = (a23*a12 - a22*a13);
195
t.GetAt(1,0) = -(a33*a21 - a31*a23);
196
t.GetAt(1,1) = (a33*a11 - a31*a13);
197
t.GetAt(1,2) = -(a23*a11 - a21*a13);
198
t.GetAt(2,0) = (a32*a21 - a31*a22);
199
t.GetAt(2,1) = -(a32*a11 - a31*a12);
200
t.GetAt(2,2) = (a22*a11 - a21*a12);
1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2014 Martin Brehm
6
2012-2014 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
28
void CxMatrix3::Dump() const
34
/* for (z2=0;z2<3;z2++)
35
if ((GetAt(z2,z) < 0) && (GetAt(z2,z) > -0.000000001))
37
mprintf("( %6.3f %6.3f %6.3f )\n",GetAt(0,z),GetAt(1,z),GetAt(2,z));
43
void CxMatrix3::MatUltra(const CxVector3 &vec1, const CxVector3 &vec2)
47
CxVector3 vectemp, vecx, vecy, vec2n, vectemp2;
48
/* float mat[3][3], mat2[3][3];
49
float vectemp[3], vecx[3], vecy[3], vec2n[3], vectemp2[3];*/
53
mprintf("\nLinAlg Checker\n\n");
54
mprintf("Vektor 1: "); vec1.Dump();
55
mprintf("\nVektor 2: "); vec2.Dump();
66
mprintf("\nVektor X: "); vecx.Dump();
67
mprintf("\nVektor Y: "); vecy.Dump();
70
// Zu erst vec1 auf X drehen
71
vectemp = CrossP(vec1,vecx);
72
if (vectemp.GetLength() != 0)
75
mprintf("\nDrehachse fuer Vektor1->X: ");
80
mprintf("\nNormalisiert: ");
85
mprintf("\nDrehwinkel: %.1f Grad\n",a*180.0/Pi);
87
mat.RotMat(vectemp,a);
91
mprintf("\nDer liegt schon auf der X-Achse!");
98
mprintf("Drehmatrix dafuer:\n"); mat.Dump();
100
mprintf("\nDamit wird Vektor1 zu "); vectemp.Dump();
101
mprintf("\nUnd Vektor2 zu "); vec2n.Dump();
104
if ((vec2-vec1).GetLength() < 0.0001) // vec1 == vec2, nichts in X-Y-Ebene drehen
112
vectemp2[1] = vec2n[1];
113
vectemp2[2] = vec2n[2];
115
#ifdef DEBUG_MATULTRA
116
mprintf("\nProjektion von Vektor2n auf YZ-Ebene: ");
120
a = Angle(vectemp2,vecy);
122
#ifdef DEBUG_MATULTRA
126
if (vectemp2.GetLength()==0)
128
eprintf("\nMatUltra: Error caught.\n");
135
#ifdef DEBUG_MATULTRA
136
mprintf("\nDrehachse fuer Vektor2->XY: ");
138
mprintf("\nDrehwinkel: %.1f Grad\n",a*180.0/Pi);
143
#ifdef DEBUG_MATULTRA
144
mprintf("Drehmatrix dafuer:\n"); mat2.Dump();
146
vectemp2 = mat2*vectemp;
147
mprintf("\nDamit wird Vektor1 zu "); vectemp2.Dump();
148
vectemp = mat2*vec2n;
149
mprintf("\nUnd Vektor2n zu "); vectemp.Dump();
154
#ifdef DEBUG_MATULTRA
155
mprintf("\nMacht diese Gesamtmatrix:\n"); Dump();
156
vectemp = *this*vec1;
157
mprintf("\nDamit wird Vektor 1 von "); vec1.Dump(); mprintf(" zu "); vectemp.Dump();
158
vectemp = *this*vec2;
159
mprintf("\nUnd Vektor 2 wird von "); vec2.Dump(); mprintf(" zu "); vectemp.Dump();
167
void CxMatrix3::Invert()
169
#define a11 GetAt(0,0)
170
#define a12 GetAt(0,1)
171
#define a13 GetAt(0,2)
172
#define a21 GetAt(1,0)
173
#define a22 GetAt(1,1)
174
#define a23 GetAt(1,2)
175
#define a31 GetAt(2,0)
176
#define a32 GetAt(2,1)
177
#define a33 GetAt(2,2)
182
det = a11 * (a33*a22 - a32*a23)
183
- a21 * (a33*a12 - a32*a13)
184
+ a31 * (a23*a12 - a22*a13);
188
eprintf("CxMatrix3::Invert(): Failed - matrix is singular.\n");
192
t.GetAt(0,0) = (a33*a22 - a32*a23);
193
t.GetAt(0,1) = -(a33*a12 - a32*a13);
194
t.GetAt(0,2) = (a23*a12 - a22*a13);
195
t.GetAt(1,0) = -(a33*a21 - a31*a23);
196
t.GetAt(1,1) = (a33*a11 - a31*a13);
197
t.GetAt(1,2) = -(a23*a11 - a21*a13);
198
t.GetAt(2,0) = (a32*a21 - a31*a22);
199
t.GetAt(2,1) = -(a32*a11 - a31*a12);
200
t.GetAt(2,2) = (a22*a11 - a21*a12);