41 |
|
template<typename Real> |
42 |
|
class SquareMatrix3 : public SquareMatrix<Real, 3> { |
43 |
|
public: |
44 |
+ |
|
45 |
+ |
typedef Real ElemType; |
46 |
+ |
typedef Real* ElemPoinerType; |
47 |
|
|
48 |
|
/** default constructor */ |
49 |
|
SquareMatrix3() : SquareMatrix<Real, 3>() { |
50 |
|
} |
51 |
|
|
52 |
+ |
/** Constructs and initializes every element of this matrix to a scalar */ |
53 |
+ |
SquareMatrix3(Real s) : SquareMatrix<Real,3>(s){ |
54 |
+ |
} |
55 |
+ |
|
56 |
+ |
/** Constructs and initializes from an array */ |
57 |
+ |
SquareMatrix3(Real* array) : SquareMatrix<Real,3>(array){ |
58 |
+ |
} |
59 |
+ |
|
60 |
+ |
|
61 |
|
/** copy constructor */ |
62 |
|
SquareMatrix3(const SquareMatrix<Real, 3>& m) : SquareMatrix<Real, 3>(m) { |
63 |
|
} |
64 |
< |
|
64 |
> |
|
65 |
|
SquareMatrix3( const Vector3<Real>& eulerAngles) { |
66 |
|
setupRotMat(eulerAngles); |
67 |
|
} |
266 |
|
* @note since simple algorithm can be applied to inverse the 3 by 3 matrix, we hide the |
267 |
|
* implementation of inverse in SquareMatrix class |
268 |
|
*/ |
269 |
< |
SquareMatrix3<Real> inverse() { |
269 |
> |
SquareMatrix3<Real> inverse() const { |
270 |
|
SquareMatrix3<Real> m; |
271 |
|
double det = determinant(); |
272 |
|
if (fabs(det) <= oopse::epsilon) { |
436 |
|
v = v.transpose(); |
437 |
|
return ; |
438 |
|
} |
439 |
+ |
|
440 |
+ |
/** |
441 |
+ |
* Return the multiplication of two matrixes (m1 * m2). |
442 |
+ |
* @return the multiplication of two matrixes |
443 |
+ |
* @param m1 the first matrix |
444 |
+ |
* @param m2 the second matrix |
445 |
+ |
*/ |
446 |
+ |
template<typename Real> |
447 |
+ |
inline SquareMatrix3<Real> operator *(const SquareMatrix3<Real>& m1, const SquareMatrix3<Real>& m2) { |
448 |
+ |
SquareMatrix3<Real> result; |
449 |
+ |
|
450 |
+ |
for (unsigned int i = 0; i < 3; i++) |
451 |
+ |
for (unsigned int j = 0; j < 3; j++) |
452 |
+ |
for (unsigned int k = 0; k < 3; k++) |
453 |
+ |
result(i, j) += m1(i, k) * m2(k, j); |
454 |
+ |
|
455 |
+ |
return result; |
456 |
+ |
} |
457 |
+ |
|
458 |
|
typedef SquareMatrix3<double> Mat3x3d; |
459 |
|
typedef SquareMatrix3<double> RotMat3x3d; |
460 |
|
|