Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Opcode::Matrix4x4 Class Reference

#include <Opcode.h>

Public Member Functions

inline_ Matrix4x4 ()
 Empty constructor. More...
 
inline_ Matrix4x4 (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
 Constructor from 16 values. More...
 
inline_ Matrix4x4 (const Matrix4x4 &mat)
 Copy constructor. More...
 
inline_ ~Matrix4x4 ()
 Destructor. More...
 
inline_ Matrix4x4Set (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
 Assign values (rotation only) More...
 
inline_ Matrix4x4Set (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
 Assign values. More...
 
inline_ void Copy (const Matrix4x4 &source)
 Copy from a Matrix4x4. More...
 
inline_ void GetRow (const udword r, HPoint &p) const
 Returns a row. More...
 
inline_ void GetRow (const udword r, Point &p) const
 Returns a row. More...
 
inline_ const HPointGetRow (const udword r) const
 Returns a row. More...
 
inline_ HPointGetRow (const udword r)
 Returns a row. More...
 
inline_ void SetRow (const udword r, const HPoint &p)
 Sets a row. More...
 
inline_ void SetRow (const udword r, const Point &p)
 Sets a row. More...
 
inline_ void GetCol (const udword c, HPoint &p) const
 Returns a column. More...
 
inline_ void GetCol (const udword c, Point &p) const
 Returns a column. More...
 
inline_ void SetCol (const udword c, const HPoint &p)
 Sets a column. More...
 
inline_ void SetCol (const udword c, const Point &p)
 Sets a column. More...
 
inline_ const HPointGetTrans () const
 Returns the translation part of the matrix. More...
 
inline_ void GetTrans (Point &p) const
 Gets the translation part of the matrix. More...
 
inline_ void SetTrans (const Point &p)
 Sets the translation part of the matrix, from a Point. More...
 
inline_ void SetTrans (const HPoint &p)
 Sets the translation part of the matrix, from a HPoint. More...
 
inline_ void SetTrans (float tx, float ty, float tz)
 Sets the translation part of the matrix, from floats. More...
 
inline_ void SetScale (const Point &p)
 Sets the scale from a Point. The point is put on the diagonal. More...
 
inline_ void SetScale (float sx, float sy, float sz)
 Sets the scale from floats. Values are put on the diagonal. More...
 
void Scale (const Point &p)
 Scales from a Point. Each row is multiplied by a component. More...
 
void Scale (float sx, float sy, float sz)
 Scales from floats. Each row is multiplied by a value. More...
 
inline_ float Trace () const
 Computes the trace. The trace is the sum of the 4 diagonal components. More...
 
inline_ float Trace3x3 () const
 Computes the trace of the upper 3x3 matrix. More...
 
inline_ void Zero ()
 Clears the matrix. More...
 
inline_ void Identity ()
 Sets the identity matrix. More...
 
inline_ bool IsIdentity () const
 Checks for identity. More...
 
inline_ BOOL IsValid () const
 Checks matrix validity. More...
 
void RotX (float angle)
 Sets a rotation matrix around the X axis. More...
 
void RotY (float angle)
 Sets a rotation matrix around the Y axis. More...
 
void RotZ (float angle)
 Sets a rotation matrix around the Z axis. More...
 
Matrix4x4Rot (float angle, Point &p1, Point &p2)
 Makes a rotation matrix about an arbitrary axis. More...
 
void Transpose ()
 Transposes the matrix. More...
 
float CoFactor (udword row, udword col) const
 Computes a cofactor. Used for matrix inversion. More...
 
float Determinant () const
 Computes the determinant of the matrix. More...
 
Matrix4x4Invert ()
 Inverts the matrix. Determinant must be different from zero, else matrix can't be inverted. More...
 
inline_ operator Matrix3x3 () const
 Casts a Matrix4x4 to a Matrix3x3. More...
 
 operator Quat () const
 Casts a Matrix4x4 to a Quat. More...
 
 operator PR () const
 Casts a Matrix4x4 to a PR. More...
 
inline_ Matrix4x4 operator+ (const Matrix4x4 &mat) const
 Operator for Matrix4x4 Plus = Matrix4x4 + Matrix4x4;. More...
 
inline_ Matrix4x4 operator- (const Matrix4x4 &mat) const
 Operator for Matrix4x4 Minus = Matrix4x4 - Matrix4x4;. More...
 
inline_ Matrix4x4 operator* (const Matrix4x4 &mat) const
 Operator for Matrix4x4 Mul = Matrix4x4 * Matrix4x4;. More...
 
inline_ HPoint operator* (const HPoint &v) const
 Operator for HPoint Mul = Matrix4x4 * HPoint;. More...
 
inline_ Point operator* (const Point &v) const
 Operator for Point Mul = Matrix4x4 * Point;. More...
 
inline_ Matrix4x4 operator* (float s) const
 Operator for Matrix4x4 Scale = Matrix4x4 * float;. More...
 
inline_ Matrix4x4 operator/ (float s) const
 Operator for Matrix4x4 Div = Matrix4x4 / float;. More...
 
inline_ Matrix4x4operator+= (const Matrix4x4 &mat)
 Operator for Matrix4x4 += Matrix4x4;. More...
 
inline_ Matrix4x4operator-= (const Matrix4x4 &mat)
 Operator for Matrix4x4 -= Matrix4x4;. More...
 
Matrix4x4operator*= (const Matrix4x4 &mat)
 Operator for Matrix4x4 *= Matrix4x4;. More...
 
inline_ Matrix4x4operator*= (float s)
 Operator for Matrix4x4 *= float;. More...
 
inline_ Matrix4x4operator/= (float s)
 Operator for Matrix4x4 /= float;. More...
 
inline_ const HPointoperator[] (int row) const
 
inline_ HPointoperator[] (int row)
 

Public Attributes

float m [4][4]
 

Friends

inline_ friend Matrix4x4 operator* (float s, const Matrix4x4 &mat)
 Operator for Matrix4x4 Scale = float * Matrix4x4;. More...
 
inline_ friend Matrix4x4 operator/ (float s, const Matrix4x4 &mat)
 Operator for Matrix4x4 Div = float / Matrix4x4;. More...
 

Detailed Description

Definition at line 22 of file Opcode.h.

Constructor & Destructor Documentation

inline_ Opcode::Matrix4x4::Matrix4x4 ( )
inline

Empty constructor.

Definition at line 29 of file Opcode.h.

39 {
inline_ Opcode::Matrix4x4::Matrix4x4 ( float  m00,
float  m01,
float  m02,
float  m03,
float  m10,
float  m11,
float  m12,
float  m13,
float  m20,
float  m21,
float  m22,
float  m23,
float  m30,
float  m31,
float  m32,
float  m33 
)
inline

Constructor from 16 values.

Definition at line 31 of file Opcode.h.

39  {
40 
inline_ Opcode::Matrix4x4::Matrix4x4 ( const Matrix4x4 mat)
inline

Copy constructor.

Definition at line 42 of file Opcode.h.

inline_ Opcode::Matrix4x4::~Matrix4x4 ( )
inline

Destructor.

Definition at line 44 of file Opcode.h.

Member Function Documentation

float Matrix4x4::CoFactor ( udword  row,
udword  col 
) const

Computes a cofactor. Used for matrix inversion.

Definition at line 82 of file IceMatrix4x4.cpp.

References f, and m.

Referenced by Determinant(), and Invert().

83 {
84  return (( m[(row+1)&3][(col+1)&3]*m[(row+2)&3][(col+2)&3]*m[(row+3)&3][(col+3)&3] +
85  m[(row+1)&3][(col+2)&3]*m[(row+2)&3][(col+3)&3]*m[(row+3)&3][(col+1)&3] +
86  m[(row+1)&3][(col+3)&3]*m[(row+2)&3][(col+1)&3]*m[(row+3)&3][(col+2)&3])
87  - (m[(row+3)&3][(col+1)&3]*m[(row+2)&3][(col+2)&3]*m[(row+1)&3][(col+3)&3] +
88  m[(row+3)&3][(col+2)&3]*m[(row+2)&3][(col+3)&3]*m[(row+1)&3][(col+1)&3] +
89  m[(row+3)&3][(col+3)&3]*m[(row+2)&3][(col+1)&3]*m[(row+1)&3][(col+2)&3])) * ((row + col) & 1 ? -1.0f : +1.0f);
90 }
inline_ void Opcode::Matrix4x4::Copy ( const Matrix4x4 source)
inline

Copy from a Matrix4x4.

Definition at line 70 of file Opcode.h.

float Matrix4x4::Determinant ( ) const

Computes the determinant of the matrix.

Definition at line 95 of file IceMatrix4x4.cpp.

References CoFactor(), and m.

Referenced by Invert().

96 {
97  return m[0][0] * CoFactor(0, 0) +
98  m[0][1] * CoFactor(0, 1) +
99  m[0][2] * CoFactor(0, 2) +
100  m[0][3] * CoFactor(0, 3);
101 }
inline_ void Opcode::Matrix4x4::GetCol ( const udword  c,
HPoint p 
) const
inline

Returns a column.

Definition at line 86 of file Opcode.h.

inline_ void Opcode::Matrix4x4::GetCol ( const udword  c,
Point p 
) const
inline

Returns a column.

Definition at line 88 of file Opcode.h.

inline_ void Opcode::Matrix4x4::GetRow ( const udword  r,
HPoint p 
) const
inline

Returns a row.

Definition at line 74 of file Opcode.h.

inline_ void Opcode::Matrix4x4::GetRow ( const udword  r,
Point p 
) const
inline

Returns a row.

Definition at line 76 of file Opcode.h.

inline_ const HPoint& Opcode::Matrix4x4::GetRow ( const udword  r) const
inline

Returns a row.

Definition at line 78 of file Opcode.h.

inline_ HPoint& Opcode::Matrix4x4::GetRow ( const udword  r)
inline

Returns a row.

Definition at line 80 of file Opcode.h.

inline_ const HPoint& Opcode::Matrix4x4::GetTrans ( ) const
inline

Returns the translation part of the matrix.

Definition at line 96 of file Opcode.h.

inline_ void Opcode::Matrix4x4::GetTrans ( Point p) const
inline

Gets the translation part of the matrix.

Definition at line 98 of file Opcode.h.

inline_ void Opcode::Matrix4x4::Identity ( )
inline

Sets the identity matrix.

Definition at line 175 of file Opcode.h.

Matrix4x4 & Matrix4x4::Invert ( )

Inverts the matrix. Determinant must be different from zero, else matrix can't be inverted.

Definition at line 106 of file IceMatrix4x4.cpp.

References CoFactor(), Determinant(), m, and MATRIX4X4_EPSILON.

107 {
108  float Det = Determinant();
109  Matrix4x4 Temp;
110 
111  if(fabsf(Det) < MATRIX4X4_EPSILON)
112  return *this; // The matrix is not invertible! Singular case!
113 
114  float IDet = 1.0f / Det;
115 
116  Temp.m[0][0] = CoFactor(0,0) * IDet;
117  Temp.m[1][0] = CoFactor(0,1) * IDet;
118  Temp.m[2][0] = CoFactor(0,2) * IDet;
119  Temp.m[3][0] = CoFactor(0,3) * IDet;
120  Temp.m[0][1] = CoFactor(1,0) * IDet;
121  Temp.m[1][1] = CoFactor(1,1) * IDet;
122  Temp.m[2][1] = CoFactor(1,2) * IDet;
123  Temp.m[3][1] = CoFactor(1,3) * IDet;
124  Temp.m[0][2] = CoFactor(2,0) * IDet;
125  Temp.m[1][2] = CoFactor(2,1) * IDet;
126  Temp.m[2][2] = CoFactor(2,2) * IDet;
127  Temp.m[3][2] = CoFactor(2,3) * IDet;
128  Temp.m[0][3] = CoFactor(3,0) * IDet;
129  Temp.m[1][3] = CoFactor(3,1) * IDet;
130  Temp.m[2][3] = CoFactor(3,2) * IDet;
131  Temp.m[3][3] = CoFactor(3,3) * IDet;
132 
133  *this = Temp;
134 
135  return *this;
136 }
inline_ bool Opcode::Matrix4x4::IsIdentity ( ) const
inline

Checks for identity.

Definition at line 177 of file Opcode.h.

inline_ BOOL Opcode::Matrix4x4::IsValid ( ) const
inline

Checks matrix validity.

Definition at line 202 of file Opcode.h.

inline_ Opcode::Matrix4x4::operator Matrix3x3 ( ) const
inline

Casts a Matrix4x4 to a Matrix3x3.

Definition at line 245 of file Opcode.h.

Opcode::Matrix4x4::operator PR ( ) const

Casts a Matrix4x4 to a PR.

Opcode::Matrix4x4::operator Quat ( ) const

Casts a Matrix4x4 to a Quat.

inline_ Matrix4x4 Opcode::Matrix4x4::operator* ( const Matrix4x4 mat) const
inline

Operator for Matrix4x4 Mul = Matrix4x4 * Matrix4x4;.

Definition at line 279 of file Opcode.h.

inline_ HPoint Opcode::Matrix4x4::operator* ( const HPoint v) const
inline

Operator for HPoint Mul = Matrix4x4 * HPoint;.

Definition at line 304 of file Opcode.h.

inline_ Point Opcode::Matrix4x4::operator* ( const Point v) const
inline

Operator for Point Mul = Matrix4x4 * Point;.

Definition at line 307 of file Opcode.h.

inline_ Matrix4x4 Opcode::Matrix4x4::operator* ( float  s) const
inline

Operator for Matrix4x4 Scale = Matrix4x4 * float;.

Definition at line 315 of file Opcode.h.

Matrix4x4& Opcode::Matrix4x4::operator*= ( const Matrix4x4 mat)
inline

Operator for Matrix4x4 *= Matrix4x4;.

Definition at line 377 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::operator*= ( float  s)
inline

Operator for Matrix4x4 *= float;.

Definition at line 409 of file Opcode.h.

inline_ Matrix4x4 Opcode::Matrix4x4::operator+ ( const Matrix4x4 mat) const
inline

Operator for Matrix4x4 Plus = Matrix4x4 + Matrix4x4;.

Definition at line 259 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::operator+= ( const Matrix4x4 mat)
inline

Operator for Matrix4x4 += Matrix4x4;.

Definition at line 357 of file Opcode.h.

inline_ Matrix4x4 Opcode::Matrix4x4::operator- ( const Matrix4x4 mat) const
inline

Operator for Matrix4x4 Minus = Matrix4x4 - Matrix4x4;.

Definition at line 269 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::operator-= ( const Matrix4x4 mat)
inline

Operator for Matrix4x4 -= Matrix4x4;.

Definition at line 367 of file Opcode.h.

inline_ Matrix4x4 Opcode::Matrix4x4::operator/ ( float  s) const
inline

Operator for Matrix4x4 Div = Matrix4x4 / float;.

Definition at line 335 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::operator/= ( float  s)
inline

Operator for Matrix4x4 /= float;.

Definition at line 419 of file Opcode.h.

inline_ const HPoint& Opcode::Matrix4x4::operator[] ( int  row) const
inline

Definition at line 429 of file Opcode.h.

inline_ HPoint& Opcode::Matrix4x4::operator[] ( int  row)
inline

Definition at line 430 of file Opcode.h.

Matrix4x4& Opcode::Matrix4x4::Rot ( float  angle,
Point p1,
Point p2 
)

Makes a rotation matrix about an arbitrary axis.

void Opcode::Matrix4x4::RotX ( float  angle)
inline

Sets a rotation matrix around the X axis.

Definition at line 215 of file Opcode.h.

void Opcode::Matrix4x4::RotY ( float  angle)
inline

Sets a rotation matrix around the Y axis.

Definition at line 217 of file Opcode.h.

void Opcode::Matrix4x4::RotZ ( float  angle)
inline

Sets a rotation matrix around the Z axis.

Definition at line 219 of file Opcode.h.

void Opcode::Matrix4x4::Scale ( const Point p)
inline

Scales from a Point. Each row is multiplied by a component.

Definition at line 112 of file Opcode.h.

void Opcode::Matrix4x4::Scale ( float  sx,
float  sy,
float  sz 
)
inline

Scales from floats. Each row is multiplied by a value.

Definition at line 119 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::Set ( float  m00,
float  m01,
float  m02,
float  m10,
float  m11,
float  m12,
float  m20,
float  m21,
float  m22 
)
inline

Assign values (rotation only)

Definition at line 47 of file Opcode.h.

inline_ Matrix4x4& Opcode::Matrix4x4::Set ( float  m00,
float  m01,
float  m02,
float  m03,
float  m10,
float  m11,
float  m12,
float  m13,
float  m20,
float  m21,
float  m22,
float  m23,
float  m30,
float  m31,
float  m32,
float  m33 
)
inline

Assign values.

Definition at line 57 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetCol ( const udword  c,
const HPoint p 
)
inline

Sets a column.

Definition at line 90 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetCol ( const udword  c,
const Point p 
)
inline

Sets a column.

Definition at line 92 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetRow ( const udword  r,
const HPoint p 
)
inline

Sets a row.

Definition at line 82 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetRow ( const udword  r,
const Point p 
)
inline

Sets a row.

Definition at line 84 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetScale ( const Point p)
inline

Sets the scale from a Point. The point is put on the diagonal.

Definition at line 108 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetScale ( float  sx,
float  sy,
float  sz 
)
inline

Sets the scale from floats. Values are put on the diagonal.

Definition at line 110 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetTrans ( const Point p)
inline

Sets the translation part of the matrix, from a Point.

Definition at line 100 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetTrans ( const HPoint p)
inline

Sets the translation part of the matrix, from a HPoint.

Definition at line 102 of file Opcode.h.

inline_ void Opcode::Matrix4x4::SetTrans ( float  tx,
float  ty,
float  tz 
)
inline

Sets the translation part of the matrix, from floats.

Definition at line 104 of file Opcode.h.

inline_ float Opcode::Matrix4x4::Trace ( ) const
inline

Computes the trace. The trace is the sum of the 4 diagonal components.

Definition at line 169 of file Opcode.h.

inline_ float Opcode::Matrix4x4::Trace3x3 ( ) const
inline

Computes the trace of the upper 3x3 matrix.

Definition at line 171 of file Opcode.h.

void Opcode::Matrix4x4::Transpose ( )
inline

Transposes the matrix.

Definition at line 225 of file Opcode.h.

inline_ void Opcode::Matrix4x4::Zero ( )
inline

Clears the matrix.

Definition at line 173 of file Opcode.h.

Friends And Related Function Documentation

inline_ friend Matrix4x4 operator* ( float  s,
const Matrix4x4 mat 
)
friend

Operator for Matrix4x4 Scale = float * Matrix4x4;.

Definition at line 325 of file Opcode.h.

inline_ friend Matrix4x4 operator/ ( float  s,
const Matrix4x4 mat 
)
friend

Operator for Matrix4x4 Div = float / Matrix4x4;.

Definition at line 347 of file Opcode.h.

Member Data Documentation


The documentation for this class was generated from the following files: