41 |
|
Rotating points in space can be performed by a vector-matrix |
42 |
|
multiplication. The matrix3x3 class is designed as a helper to the |
43 |
|
vector3 class for rotating points in space. The rotation matrix may be |
44 |
< |
initialised by passing in the array of doubleing point values, by |
44 |
> |
initialised by passing in the array of floating point values, by |
45 |
|
passing euler angles, or a rotation vector and angle of rotation about |
46 |
|
that vector. Once set, the matrix3x3 class can be used to rotate |
47 |
|
vectors by the overloaded multiplication operator. The following |
102 |
|
generate the 0-matrix. If the length of the axis is close to |
103 |
|
zero, but not == 0.0, this method may behave in unexpected |
104 |
|
ways and return almost random results; details may depend on |
105 |
< |
your particular doubleing point implementation. The use of this |
105 |
> |
your particular floating point implementation. The use of this |
106 |
|
method is therefore highly discouraged, unless you are certain |
107 |
|
that the length is in a reasonable range, away from 0.0 |
108 |
|
(Stefan Kebekus) |
137 |
|
generate the 0-matrix. If the length of the axis is close to |
138 |
|
zero, but not == 0.0, this method may behave in unexpected ways |
139 |
|
and return almost random results; details may depend on your |
140 |
< |
particular doubleing point implementation. The use of this method |
140 |
> |
particular floating point implementation. The use of this method |
141 |
|
is therefore highly discouraged, unless you are certain that the |
142 |
|
length is in a reasonable range, away from 0.0 (Stefan |
143 |
|
Kebekus) |
177 |
|
#undef y |
178 |
|
#undef z |
179 |
|
|
180 |
< |
void matrix3x3::SetColumn(int col, const vector3 &v) |
180 |
> |
void matrix3x3::SetColumn(int col, const vector3 &v) throw(OBError) |
181 |
|
{ |
182 |
|
if (col > 2) |
183 |
|
{ |
184 |
< |
obErrorLog.ThrowError(__func__, |
185 |
< |
"The method was called with col > 2.", obError); |
184 |
> |
OBError er("matrix3x3::SetColumn(int col, const vector3 &v)", |
185 |
> |
"The method was called with col > 2.", |
186 |
> |
"This is a programming error in your application."); |
187 |
> |
throw er; |
188 |
|
} |
189 |
|
|
190 |
|
ele[0][col] = v.x(); |
192 |
|
ele[2][col] = v.z(); |
193 |
|
} |
194 |
|
|
195 |
< |
void matrix3x3::SetRow(int row, const vector3 &v) |
195 |
> |
void matrix3x3::SetRow(int row, const vector3 &v) throw(OBError) |
196 |
|
{ |
197 |
|
if (row > 2) |
198 |
|
{ |
199 |
< |
obErrorLog.ThrowError(__func__, |
200 |
< |
"The method was called with row > 2.", obError); |
199 |
> |
OBError er("matrix3x3::SetRow(int row, const vector3 &v)", |
200 |
> |
"The method was called with row > 2.", |
201 |
> |
"This is a programming error in your application."); |
202 |
> |
throw er; |
203 |
|
} |
204 |
|
|
205 |
|
ele[row][0] = v.x(); |
207 |
|
ele[row][2] = v.z(); |
208 |
|
} |
209 |
|
|
210 |
< |
vector3 matrix3x3::GetColumn(unsigned int col) |
210 |
> |
vector3 matrix3x3::GetColumn(unsigned int col) const throw(OBError) |
211 |
|
{ |
212 |
|
if (col > 2) |
213 |
|
{ |
214 |
< |
obErrorLog.ThrowError(__func__, |
215 |
< |
"The method was called with col > 2.", obError); |
214 |
> |
OBError er("matrix3x3::GetColumn(unsigned int col) const", |
215 |
> |
"The method was called with col > 2.", |
216 |
> |
"This is a programming error in your application."); |
217 |
> |
throw er; |
218 |
|
} |
219 |
|
|
220 |
|
return vector3(ele[0][col], ele[1][col], ele[2][col]); |
221 |
|
} |
222 |
|
|
223 |
< |
vector3 matrix3x3::GetRow(unsigned int row) |
223 |
> |
vector3 matrix3x3::GetRow(unsigned int row) const throw(OBError) |
224 |
|
{ |
225 |
|
if (row > 2) |
226 |
|
{ |
227 |
< |
obErrorLog.ThrowError(__func__, |
228 |
< |
"The method was called with row > 2.", obError); |
227 |
> |
OBError er("matrix3x3::GetRow(unsigned int row) const", |
228 |
> |
"The method was called with row > 2.", |
229 |
> |
"This is a programming error in your application."); |
230 |
> |
throw er; |
231 |
|
} |
232 |
|
|
233 |
|
return vector3(ele[row][0], ele[row][1], ele[row][2]); |
289 |
|
|
290 |
|
\warning If the determinant is close to zero, but not == 0.0, |
291 |
|
this method may behave in unexpected ways and return almost |
292 |
< |
random results; details may depend on your particular doubleing |
292 |
> |
random results; details may depend on your particular floating |
293 |
|
point implementation. The use of this method is therefore highly |
294 |
|
discouraged, unless you are certain that the determinant is in a |
295 |
|
reasonable range, away from 0.0 (Stefan Kebekus) |
296 |
|
*/ |
297 |
< |
matrix3x3 matrix3x3::inverse(void) |
297 |
> |
matrix3x3 matrix3x3::inverse(void) const throw(OBError) |
298 |
|
{ |
299 |
|
double det = determinant(); |
300 |
|
if (fabs(det) <= 1e-6) |
301 |
|
{ |
302 |
< |
obErrorLog.ThrowError(__func__, |
303 |
< |
"The method was called on a matrix with |determinant| <= 1e-6.", obError); |
302 |
> |
OBError er("matrix3x3::invert(void)", |
303 |
> |
"The method was called on a matrix with |determinant| <= 1e-6.", |
304 |
> |
"This is a runtime or a programming error in your application."); |
305 |
> |
throw er; |
306 |
|
} |
307 |
|
|
308 |
|
matrix3x3 inverse; |
435 |
|
\endcode |
436 |
|
|
437 |
|
*/ |
438 |
< |
matrix3x3 matrix3x3::findEigenvectorsIfSymmetric(vector3 &eigenvals) |
438 |
> |
matrix3x3 matrix3x3::findEigenvectorsIfSymmetric(vector3 &eigenvals) const throw(OBError) |
439 |
|
{ |
440 |
|
matrix3x3 result; |
441 |
|
|
442 |
|
if (!isSymmetric()) |
443 |
|
{ |
444 |
< |
obErrorLog.ThrowError(__func__, |
445 |
< |
"The method was called on a matrix that was not symmetric, i.e. where isSymetric() == false.", obError); |
444 |
> |
OBError er("matrix3x3::findEigenvectorsIfSymmetric(vector3 &eigenvals) const throw(OBError)", |
445 |
> |
"The method was called on a matrix that was not symmetric, i.e. where isSymetric() == false.", |
446 |
> |
"This is a runtime or a programming error in your application."); |
447 |
> |
throw er; |
448 |
|
} |
449 |
|
|
450 |
|
double d[3]; |