Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

QUAT Class Reference

#include <quat.h>

List of all members.

Public Methods

 QUAT (float sx=0, float sy=0, float sz=0, float sw=1)
 ~QUAT ()
void Set ()
void CopyQuat (QUAT q)
void Set (float sx, float sy, float sz, float sw)
void AxisAngleToQuat (VECTOR axis, float theta)
void EulerToQuat (float pitch, float yaw, float roll)
void NormaliseQuat ()
float MagnitudeQuat ()
void MultQuat (QUAT q)

Public Attributes

float x
float y
float z
float w


Constructor & Destructor Documentation

QUAT::QUAT float    sx = 0,
float    sy = 0,
float    sz = 0,
float    sw = 1
 

Definition at line 7 of file quat.cpp.

00008 :
00009     x(sx),
00010     y(sy),
00011     z(sz),
00012         w(sw)
00013 {
00014 }

QUAT::~QUAT  
 

Definition at line 16 of file quat.cpp.

00017 {
00018 }


Member Function Documentation

void QUAT::AxisAngleToQuat VECTOR    axis,
float    theta
 

Definition at line 36 of file quat.cpp.

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

00037 {
00038         float halfTheta = theta * 0.5;
00039         float cosHalfTheta = cos(halfTheta);
00040         float sinHalfTheta = sin(halfTheta);
00041         x = axis.x * sinHalfTheta;
00042         y = axis.y * sinHalfTheta;
00043         z = axis.z * sinHalfTheta;
00044         w = cosHalfTheta;
00045 }

void QUAT::CopyQuat QUAT    q
 

Definition at line 28 of file quat.cpp.

References w, x, y, and z.

Referenced by MultQuat().

00029 {
00030     x = q.x;
00031     y = q.y;
00032     z = q.z;
00033     w = q.w;
00034 }

void QUAT::EulerToQuat float    pitch,
float    yaw,
float    roll
 

Definition at line 47 of file quat.cpp.

References w, x, y, and z.

Referenced by OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::MoveX(), OBJECT::MoveY(), and OBJECT::Rotate().

00048 {
00049         float cr, cp, cy, sr, sp, sy, cpcy, spsy;  // calculate trig identities
00050         cr = cos(roll/2);
00051         cp = cos(pitch/2);
00052         cy = cos(yaw/2);
00053         sr = sin(roll/2);
00054         sp = sin(pitch/2);
00055         sy = sin(yaw/2);
00056         cpcy = cp * cy;
00057         spsy = sp * sy;
00058         w = cr * cpcy + sr * spsy;
00059         x = sr * cpcy - cr * spsy;
00060         y = cr * sp * cy + sr * cp * sy;
00061         z = cr * cp * sy - sr * sp * cy;
00062 }

float QUAT::MagnitudeQuat  
 

Definition at line 64 of file quat.cpp.

References w, x, y, and z.

Referenced by NormaliseQuat().

00065 {
00066       return( sqrt(w*w+x*x+y*y+z*z));
00067 }

void QUAT::MultQuat QUAT    q
 

Definition at line 79 of file quat.cpp.

References CopyQuat(), VECTOR::CrossProduct(), VECTOR::DotProduct(), w, x, VECTOR::x, y, VECTOR::y, z, and VECTOR::z.

Referenced by OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::MoveX(), OBJECT::MoveY(), and OBJECT::Rotate().

00080 {
00081       QUAT q3;
00082       VECTOR vectorq1;
00083       VECTOR vectorq2;
00084       vectorq1.x = x;
00085       vectorq1.y = y;
00086       vectorq1.z = z;
00087       vectorq2.x = q.x;
00088       vectorq2.y = q.y;
00089       vectorq2.z = q.z;
00090 
00091       VECTOR tempvec1;
00092       VECTOR tempvec2;
00093       VECTOR tempvec3;
00094       tempvec1 = vectorq1;
00095       q3.w = (w*q.w) - tempvec1.DotProduct(vectorq2);
00096       tempvec1.CrossProduct(vectorq2);
00097       tempvec2.x = w * q.x;
00098       tempvec2.y = w * q.y;
00099       tempvec2.z = w * q.z;
00100       tempvec3.x = q.w * x;
00101       tempvec3.y = q.w * y;
00102       tempvec3.z = q.w * z;
00103       q3.x = tempvec1.x + tempvec2.x + tempvec3.x;
00104       q3.y = tempvec1.y + tempvec2.y + tempvec3.y;
00105       q3.z = tempvec1.z + tempvec2.z + tempvec3.z;
00106       CopyQuat(q3);
00107 }

void QUAT::NormaliseQuat  
 

Definition at line 69 of file quat.cpp.

References MagnitudeQuat(), w, x, y, and z.

00070 {
00071       float Mag;
00072       Mag = MagnitudeQuat();
00073       w = w/Mag;
00074       x = x/Mag;
00075       y = y/Mag;
00076       z = z/Mag;
00077 }

void QUAT::Set float    sx,
float    sy,
float    sz,
float    sw
[inline]
 

Definition at line 17 of file quat.h.

References w, x, y, and z.

00017 {x = sx, y = sy, z = sz, w = sw;}

void QUAT::Set  
 

Definition at line 20 of file quat.cpp.

References w, x, y, and z.

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

00021 {
00022     x = 0.0;
00023     y = 0.0;
00024     z = 0.0;
00025     w = 1.0;
00026 }


Member Data Documentation

float QUAT::w
 

Definition at line 27 of file quat.h.

Referenced by AxisAngleToMatrix(), AxisAngleToQuat(), CopyQuat(), EulerToQuat(), EulerToQuat(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), MagnitudeQuat(), MagnitudeQuat(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), MultQuat(), MultQuat(), NormaliseQuat(), NormaliseQuat(), MATRIX::QuatToMatrix(), QuatToMatrix(), and Set().

float QUAT::x
 

Definition at line 24 of file quat.h.

Referenced by AxisAngleToMatrix(), AxisAngleToQuat(), CopyQuat(), EulerToQuat(), EulerToQuat(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), MagnitudeQuat(), MagnitudeQuat(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), MultQuat(), MultQuat(), NormaliseQuat(), NormaliseQuat(), MATRIX::QuatToMatrix(), QuatToMatrix(), and Set().

float QUAT::y
 

Definition at line 25 of file quat.h.

Referenced by AxisAngleToMatrix(), AxisAngleToQuat(), CopyQuat(), EulerToQuat(), EulerToQuat(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), MagnitudeQuat(), MagnitudeQuat(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), MultQuat(), MultQuat(), NormaliseQuat(), NormaliseQuat(), MATRIX::QuatToMatrix(), QuatToMatrix(), and Set().

float QUAT::z
 

Definition at line 26 of file quat.h.

Referenced by AxisAngleToMatrix(), AxisAngleToQuat(), CopyQuat(), EulerToQuat(), EulerToQuat(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), MagnitudeQuat(), MagnitudeQuat(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), MultQuat(), MultQuat(), NormaliseQuat(), NormaliseQuat(), MATRIX::QuatToMatrix(), QuatToMatrix(), and Set().


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