7 #ifndef CAFU_MATH_MATRIX_3X3_HPP_INCLUDED
8 #define CAFU_MATH_MATRIX_3X3_HPP_INCLUDED
10 #include "Vector3.hpp"
17 template<
class T>
class AnglesT;
18 template<
class T>
class QuaternionT;
30 for (
unsigned long i=0; i<3; i++)
31 for (
unsigned long j=0; j<3; j++)
32 m[i][j]=(i==j) ? T(1.0) : 0;
38 for (
unsigned long i=0; i<3; i++)
39 for (
unsigned long j=0; j<3; j++)
46 for (
unsigned long i=0; i<3; i++)
47 for (
unsigned long j=0; j<3; j++)
56 m[0][0]=m00;
m[0][1]=m01;
m[0][2]=m02;
57 m[1][0]=m10;
m[1][1]=m11;
m[1][2]=m12;
58 m[2][0]=m20;
m[2][1]=m21;
m[2][2]=m22;
84 const T*
operator [] (
unsigned long i)
const { assert(i<3);
return m[i]; }
108 for (
unsigned long i=0; i<3; i++)
109 for (
unsigned long j=0; j<3; j++)
110 if (
m[i][j]!=Other.m[i][j])
121 return !(*
this==Other);
141 for (
unsigned long i=0; i<3; i++)
142 for (
unsigned long j=0; j<3; j++)
143 if (fabs(
m[i][j]-Other.m[i][j]) > Epsilon)
155 m[1][0]*v.
x +
m[1][1]*v.
y +
m[1][2]*v.
z,
156 m[2][0]*v.
x +
m[2][1]*v.
y +
m[2][2]*v.
z);
165 m[0][1]*v.
x +
m[1][1]*v.
y +
m[2][1]*v.
z,
166 m[0][2]*v.
x +
m[1][2]*v.
y +
m[2][2]*v.
z);
173 void Mul(
const T v[3], T out[3])
const
176 T Result[3]={
m[0][0]*v[0] +
m[0][1]*v[1] +
m[0][2]*v[2],
177 m[1][0]*v[0] +
m[1][1]*v[1] +
m[1][2]*v[2],
178 m[2][0]*v[0] +
m[2][1]*v[1] +
m[2][2]*v[2] };
180 for (
int i=0; i<3; i++) out[i]=Result[i];
bool operator!=(const Matrix3x3T &Other) const
Determines if this matrix is not equal to Other.
Definition: Matrix3x3.hpp:119
Matrix3x3T(T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22)
Constructor for creating an arbitrary matrix.
Definition: Matrix3x3.hpp:52
Matrix3x3T GetTranspose() const
Returns the transpose of this matrix.
Definition: Matrix3x3.cpp:409
void Scale_MS(T sx, T sy, T sz)
Computes M=M*S, where S=GetScaleMatrix (sx, sy, sz).
Definition: Matrix3x3.cpp:192
Vector3T< T > MulTranspose(const Vector3T< T > &v) const
A shortcut for M.GetTranspose()*v, where M is this matrix.
Definition: Matrix3x3.hpp:162
Vector3T< T > Mul(const Vector3T< T > &v) const
Computes M*v, where M is this matrix.
Definition: Matrix3x3.hpp:152
This class represents a triple of angles.
Definition: Angles.hpp:71
void RotateX_RM(T Angle)
Computes M=R*M, where R=GetRotateXMatrix (Angle).
Definition: Matrix3x3.cpp:231
Matrix3x3T(const double M[3][3])
Constructor for creating an arbitrary matrix.
Definition: Matrix3x3.hpp:44
void Scale_SM(T sx, T sy, T sz)
Computes M=S*M, where S=GetScaleMatrix (sx, sy, sz).
Definition: Matrix3x3.cpp:203
static Matrix3x3T GetFromAngles_COMPAT(const AnglesT< T > &Angles)
Returns a rotation matrix built from the given angles in a "compatibility-to-old-code" fashion...
Definition: Matrix3x3.cpp:143
Matrix3x3T(const float M[3][3])
Constructor for creating an arbitrary matrix.
Definition: Matrix3x3.hpp:36
Vector3T< T > GetAxis(unsigned int i) const
Returns the i-th column of this matrix.
Definition: Matrix3x3.hpp:88
T m[3][3]
The matrix values.
Definition: Matrix3x3.hpp:200
static const Matrix3x3T< T > Identity
Identity matrix.
Definition: Matrix3x3.hpp:202
bool IsEqual(const Matrix3x3T &Other, const T Epsilon=0) const
Returns whether this matrix is equal to Other.
Definition: Matrix3x3.hpp:139
T y
The y-component of this vector.
Definition: Vector3.hpp:41
Matrix3x3T operator*(const Matrix3x3T &Other) const
Computes M*Other, that is, the matrix product of this and the Other matrix.
Definition: Matrix3x3.cpp:175
T * operator[](unsigned long i)
Returns the i-th row of this matrix.
Definition: Matrix3x3.hpp:81
void RotateZ_RM(T Angle)
Computes M=R*M, where R=GetRotateZMatrix (Angle).
Definition: Matrix3x3.cpp:299
This class represents a polymorphic 3-dimensional vector.
Definition: Misc.hpp:11
static Matrix3x3T GetRotateZMatrix(T Angle)
Returns a rotation matrix about Angle degrees around the z-axis.
Definition: Matrix3x3.cpp:105
static Matrix3x3T GetScaleMatrix(T sx, T sy, T sz)
Returns a scale matrix with scale factors (sx sy sz).
Definition: Matrix3x3.cpp:61
void Mul(const T v[3], T out[3]) const
Computes M*v, where M is this matrix.
Definition: Matrix3x3.hpp:173
void RotateX_MR(T Angle)
Computes M=M*R, where R=GetRotateXMatrix (Angle).
Definition: Matrix3x3.cpp:214
static Matrix3x3T GetRotateMatrix(T Angle, const Vector3T< T > &Axis)
Returns a rotation matrix about Angle degrees around Axis.
Definition: Matrix3x3.cpp:121
void RotateY_RM(T Angle)
Computes M=R*M, where R=GetRotateYMatrix (Angle).
Definition: Matrix3x3.cpp:265
Matrix3x3T()
The default constructor for creating a "1" (identity) matrix.
Definition: Matrix3x3.hpp:28
AnglesT< T > ToAngles_COMPAT() const
Converts the rotation that is described by this matrix to an AnglesT<T> instance that describes the s...
Definition: Matrix3x3.cpp:421
void RotateY_MR(T Angle)
Computes M=M*R, where R=GetRotateYMatrix (Angle).
Definition: Matrix3x3.cpp:248
T z
The z-component of this vector.
Definition: Vector3.hpp:42
void RotateZ_MR(T Angle)
Computes M=M*R, where R=GetRotateZMatrix (Angle).
Definition: Matrix3x3.cpp:282
Matrix3x3T GetInverse(bool *Result=NULL) const
Computes the inverse of this matrix.
Definition: Matrix3x3.cpp:316
This class represents a quaternion.
Definition: Angles.hpp:18
T x
The x-component of this vector.
Definition: Vector3.hpp:40
static Matrix3x3T GetRotateXMatrix(T Angle)
Returns a rotation matrix about Angle degrees around the x-axis.
Definition: Matrix3x3.cpp:73
static Matrix3x3T GetRotateYMatrix(T Angle)
Returns a rotation matrix about Angle degrees around the y-axis.
Definition: Matrix3x3.cpp:89
This class represents a generic 3x3 matrix.
Definition: Angles.hpp:17
bool operator==(const Matrix3x3T &Other) const
Determines if this matrix is equal to Other.
Definition: Matrix3x3.hpp:106