Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GAngles Class Reference

Represents a set of Euler angles (pitch, yaw, and roll). More...

#include <gauge3d/3dmath/angles.h>

List of all members.

Public Types

typedef float tAngle

Public Methods

 GAngles ()
 Leaves pitch, yaw, and roll unititialized.

 GAngles (tAngle pitch,tAngle yaw,tAngle roll)
 Sets pitch, yaw, and roll manually.

 GAngles (const GQuaternion &quat)
 Converts a quaternion into Euler angles.

void Rotate (const GVector in[],GVector out[],int num)const
 Rotate a set of vectors by the angles. More...

void MakeVectors (GVector *forward,GVector *up=NULL,GVector *right=NULL)const
 Finds forward, up, and right vectors for the angles. More...

void SetDirection (const GVector &forward)
 Sets the angles to point in the given direction. More...

void SetDirection (const GVector &forward,const GVector &up)
 Sets the angles so that the given forward and up vectors are valid. More...

const GAngles& operator+= (const GAngles &other)
 Component-wise addition (fast).

GAngles operator+ (const GAngles &other)
 Component-wise addition (fast).

const GAngles& operator-= (const GAngles &other)
 Component-wise subtraction (fast).

GAngles operator- (const GAngles &other)
 Component-wise subtraction (fast).

GAngles operator * (GCoordinate a)
 Component-wise multiplication (fast).

const GAngles& operator *= (GCoordinate a)
 Component-wise multiplication (fast).

GAngles operator * (const GAngles &other)
 Combines the angles "correctly" (slow). More...

const GAngles& operator *= (const GAngles &other)
 Combines the angles "correctly" (slow). More...

bool operator== (const GAngles &other)const
 Checks for equality with error tolerance.

 operator GQuaternion ()const
 Converts to a GQuaternion.


Public Attributes

Angle Values
All angles are in radians.

tAngle mPitch
tAngle mYaw
tAngle mRoll

Static Public Methods

tAngle Degrees2Radians (tAngle degrees)
 Convert degrees to radians.

tAngle Radians2Degrees (tAngle radians)
 Convert radians to degrees.


Related Functions

(Note that these are not member functions.)

GAngles operator * (GCoordinate coord,const GAngles &angles)
 Component-wise subtraction (fast).


Detailed Description

Represents a set of Euler angles (pitch, yaw, and roll).

See also:
GQuaternion

Euler angles are more intuitive than quaternions, especially in certain types of games (such as 3D shooters). However, Euler angles have many limitations, and are not very elegant mathematically. Fortunately, you can convert Euler angles into quaternions and vice versa.

A pitch, yaw, and roll of zero points in the direction of GVECTOR_FORWARD. Pitch rotates clockwise around the X axis, yaw rotates clockwise around the Z axis, and roll rotates clockwise around the Y axis. When rotating a vector, roll is applied first, then pitch, then yaw.


Member Function Documentation

void GAUGE3D::GAngles::Rotate ( const GVector in[],
GVector out[],
int num ) const
 

Rotate a set of vectors by the angles.

Parameters:
in   An array of vectors to rotate.
out   Location to which to write the rotated vectors. May be the same as in.
num   Number of vectors to rotate.
Remarks:
Rotating many vectors at once is much faster than rotating vectors individually.

void GAUGE3D::GAngles::MakeVectors ( GVector * forward,
GVector * up = NULL,
GVector * right = NULL ) const
 

Finds forward, up, and right vectors for the angles.

Parameters:
forward   The location to write the forward vector, or NULL if it should not be calculated.
up   The location to write the up vector, or NULL if it should not be calculated.
right   The location to write the right vector, or NULL if it should not be calculated.

MakeVectors takes an angle and converts it to a vector pointing forward, a vector pointing right, and a vector pointing up, according to the direction the angles are pointing. In other words, it is similar to calling Rotate() with the input being the vectors GVECTOR_FORWARD, GVECTOR_UP, and GVECTOR_RIGHT.

void GAUGE3D::GAngles::SetDirection ( const GVector & forward )
 

Sets the angles to point in the given direction.

SetDirection takes a vector and sets the pitch and yaw such that that vector points forwards. Roll is set to zero.

void GAUGE3D::GAngles::SetDirection ( const GVector & forward,
const GVector & up )
 

Sets the angles so that the given forward and up vectors are valid.

This version sets pitch, yaw, and roll so that both the given vectors are equal to what you'd get if you called MakeVectors.

GAngles GAUGE3D::GAngles::operator * ( const GAngles & other ) [inline]
 

Combines the angles "correctly" (slow).

Multiplication between GAngles objects is done by converting them to GQuaternion's, multiplying those, and then converting the result back to a GAngles. This results in a more correct combination than simply adding the components does, but it takes longer.

const GAngles & GAUGE3D::GAngles::operator *= ( const GAngles & other )
 

Combines the angles "correctly" (slow).

Multiplication between GAngles objects is done by converting them to GQuaternion's, multiplying those, and then converting the result back to a GAngles. This results in a more correct combination than simply adding the components does, but it takes longer.


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:33 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000