Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

MATRIX Class Reference

#include <matrix.h>

List of all members.

Public Methods

 MATRIX ()
 ~MATRIX ()
void LoadIdentity ()
void CopyMatrix (float m[16])
void MultMatrix (float m[16])
void MatrixInverse ()
void MatrixFromAxisAngle (VECTOR axis, float theta)
void QuatToMatrix (QUAT quat)

Public Attributes

float Element [16]


Constructor & Destructor Documentation

MATRIX::MATRIX  
 

Definition at line 5 of file matrix.cpp.

References LoadIdentity().

00006 {
00007     LoadIdentity();
00008 }

MATRIX::~MATRIX  
 

Definition at line 10 of file matrix.cpp.

00011 {
00012 }


Member Function Documentation

void MATRIX::CopyMatrix float    m[16]
 

Definition at line 37 of file matrix.cpp.

References Element.

Referenced by MatrixInverse().

00038 {
00039         Element[0 ] = m[0 ];
00040         Element[1 ] = m[1 ];
00041         Element[2 ] = m[2 ];
00042         Element[3 ] = m[3 ];
00043         Element[4 ] = m[4 ];
00044         Element[5 ] = m[5 ];
00045         Element[6 ] = m[6 ];
00046         Element[7 ] = m[7 ];
00047         Element[8 ] = m[8 ];
00048         Element[9 ] = m[9 ];
00049         Element[10] = m[10];
00050         Element[11] = m[11];
00051         Element[12] = m[12];
00052         Element[13] = m[13];
00053         Element[14] = m[14];
00054         Element[15] = m[15];
00055 }

void MATRIX::LoadIdentity  
 

Definition at line 14 of file matrix.cpp.

References Element.

Referenced by MATRIX(), CAMERA::Reset(), and BULLET::Reset().

00015 {
00016     Element[0]=1.0f;
00017         Element[1]=0.0f;
00018         Element[2]=0.0f;
00019         Element[3]=0.0f;
00020 
00021         Element[4]=0.0f;
00022         Element[5]=1.0f;
00023         Element[6]=0.0f;
00024         Element[7]=0.0f;
00025 
00026         Element[8]=0.0f;
00027         Element[9]=0.0f;
00028         Element[10]=1.0f;
00029         Element[11]=0.0f;
00030 
00031         Element[12]=0.0f;
00032         Element[13]=0.0f;
00033         Element[14]=0.0f;
00034         Element[15]=1.0f;
00035 }

void MATRIX::MatrixFromAxisAngle VECTOR    axis,
float    theta
 

Definition at line 167 of file matrix.cpp.

References Element, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00168 {
00169         QUAT q;
00170         float halfTheta = theta * 0.5;
00171         float cosHalfTheta = cos(halfTheta);
00172         float sinHalfTheta = sin(halfTheta);
00173         float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
00174         q.x = axis.x * sinHalfTheta;
00175         q.y = axis.y * sinHalfTheta;
00176         q.z = axis.z * sinHalfTheta;
00177         q.w = cosHalfTheta;
00178         xs = q.x * 2;  ys = q.y * 2;  zs = q.z * 2;
00179         wx = q.w * xs; wy = q.w * ys; wz = q.w * zs;
00180         xx = q.x * xs; xy = q.x * ys; xz = q.x * zs;
00181         yy = q.y * ys; yz = q.y * zs; zz = q.z * zs;
00182         Element[0] = 1 - (yy + zz);
00183         Element[1] = xy - wz;
00184         Element[2] = xz + wy;
00185         Element[4] = xy + wz;
00186         Element[5] = 1 - (xx + zz);
00187         Element[6] = yz - wx;
00188         Element[8] = xz - wy;
00189         Element[9] = yz + wx;
00190         Element[10] = 1 - (xx + yy);
00191         Element[12] = Element[13] = Element[14] = Element[3] = Element[7] = Element[11] = 0;
00192         Element[15] = 1;
00193 }

void MATRIX::MatrixInverse  
 

Definition at line 144 of file matrix.cpp.

References CopyMatrix(), and Element.

Referenced by CAMERA::Apply().

00145  {
00146       MATRIX temp;
00147 
00148       temp.CopyMatrix(this->Element);
00149 
00150       Element[0 ] = temp.Element[0 ];
00151       Element[1 ] = temp.Element[4 ];
00152       Element[2 ] = temp.Element[8 ];
00153 
00154       Element[4 ] = temp.Element[1 ];
00155       Element[5 ] = temp.Element[5 ];
00156       Element[6 ] = temp.Element[9 ];
00157 
00158       Element[8 ] = temp.Element[2 ];
00159       Element[9 ] = temp.Element[6 ];
00160       Element[10] = temp.Element[10];
00161 
00162       Element[12] *= -1.0f;
00163       Element[13] *= -1.0f;
00164       Element[14] *= -1.0f;
00165 }

void MATRIX::MultMatrix float    m[16]
 

void MATRIX::QuatToMatrix QUAT    quat
 

Definition at line 195 of file matrix.cpp.

References Element, QUAT::w, QUAT::x, QUAT::y, and QUAT::z.

Referenced by CAMERA::Apply(), BULLET::Draw(), and DrawMuzzleFlash().

00196 {
00197       float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
00198       // calculate coefficients
00199       x2 = quat.x + quat.x;
00200       y2 = quat.y + quat.y;
00201       z2 = quat.z + quat.z;
00202       xx = quat.x * x2;
00203       xy = quat.x * y2;
00204       xz = quat.x * z2;
00205       yy = quat.y * y2;
00206       yz = quat.y * z2;
00207       zz = quat.z * z2;
00208       wx = quat.w * x2;
00209       wy = quat.w * y2;
00210       wz = quat.w * z2;
00211       Element[0] = 1.0 - (yy + zz);
00212       Element[1] = xy - wz;
00213       Element[2] = xz + wy;
00214       Element[3] = 0.0;
00215       Element[4] = xy + wz;
00216       Element[5] = 1.0 - (xx + zz);
00217       Element[6] = yz - wx;
00218       Element[7] = 0.0;
00219       Element[8] = xz - wy;
00220       Element[9] = yz + wx;
00221       Element[10] = 1.0 - (xx + yy);
00222       Element[11] = 0.0;
00223       Element[12] = 0;
00224       Element[13] = 0;
00225       Element[14] = 0;
00226       Element[15] = 1;
00227 }


Member Data Documentation

float MATRIX::Element[16]
 

Definition at line 22 of file matrix.h.

Referenced by CAMERA::Apply(), CopyMatrix(), BULLET::Draw(), DrawHalo(), DrawImpactFlash(), DrawMuzzleFlash(), DrawSplines(), LoadIdentity(), MatrixFromAxisAngle(), MatrixInverse(), QuatToMatrix(), Bouncy::Render(), Roman::Render(), and Spark::Render().


The documentation for this class was generated from the following files:
Generated on Fri Dec 23 05:19:59 2005 for Particles by doxygen1.2.15