Al's Programming Resource Homepage  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 6 of file matrix.cpp.

References LoadIdentity().

00007 {
00008     LoadIdentity();
00009 }

MATRIX::~MATRIX  
 

Definition at line 11 of file matrix.cpp.

00012 {
00013 }


Member Function Documentation

void MATRIX::CopyMatrix float    m[16]
 

Definition at line 38 of file matrix.cpp.

References Element.

Referenced by MatrixInverse().

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

void MATRIX::LoadIdentity  
 

Definition at line 15 of file matrix.cpp.

References Element.

Referenced by MATRIX(), and CAMERA::Set().

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

void MATRIX::MatrixFromAxisAngle VECTOR    axis,
float    theta
 

Definition at line 168 of file matrix.cpp.

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

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

void MATRIX::MatrixInverse  
 

Definition at line 145 of file matrix.cpp.

References CopyMatrix(), and Element.

Referenced by CAMERA::ApplyCamera().

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

void MATRIX::MultMatrix float    m[16]
 

void MATRIX::QuatToMatrix QUAT    quat
 

Definition at line 196 of file matrix.cpp.

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

Referenced by CAMERA::ApplyCamera().

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


Member Data Documentation

float MATRIX::Element[16]
 

Definition at line 22 of file matrix.h.

Referenced by CAMERA::ApplyCamera(), CopyMatrix(), LoadIdentity(), MatrixFromAxisAngle(), MatrixInverse(), and QuatToMatrix().


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