Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

angles_t Class Reference

#include <math_angles.h>


Public Member Functions

 angles_t (const idVec3_t &vec)
 angles_t (float pitch, float yaw, float roll)
 angles_t ()
 angles_t (const idVec3_t &vec)
 angles_t (float pitch, float yaw, float roll)
 angles_t ()
angles_tNormalize180 (void)
angles_tNormalize180 (void)
angles_tNormalize360 (void)
angles_tNormalize360 (void)
angles_toperator *= (float a)
angles_toperator *= (float a)
 operator vec3_p ()
 operator vec3_p ()
angles_toperator+= (idVec3_t const &a)
angles_toperator+= (angles_t const &a)
angles_toperator+= (idVec3_t const &a)
angles_toperator+= (angles_t const &a)
angles_toperator-= (angles_t &a)
angles_toperator-= (angles_t &a)
void operator= (idVec3_t const &a)
void operator= (angles_t const &a)
void operator= (idVec3_t const &a)
void operator= (angles_t const &a)
float & operator[] (int index)
float operator[] (int index) const
float & operator[] (int index)
float operator[] (int index) const
void set (float pitch, float yaw, float roll)
void set (float pitch, float yaw, float roll)
idVec3_t toForward (void)
idVec3_t toForward (void)
void toVectors (idVec3_t *forward, idVec3_t *right=NULL, idVec3_t *up=NULL)
void toVectors (idVec3_t *forward, idVec3_t *right=NULL, idVec3_t *up=NULL)
angles_tZero (void)
angles_tZero (void)

Data Fields

float pitch
float roll
float yaw

Friends

angles_t operator * (float a, const angles_t &b)
angles_t operator * (const angles_t &a, float b)
angles_t operator * (float a, const angles_t &b)
angles_t operator * (const angles_t &a, float b)
int operator!= (angles_t &a, angles_t &b)
int operator!= (angles_t &a, angles_t &b)
angles_t operator+ (const angles_t &a, const angles_t &b)
angles_t operator+ (const angles_t &a, const angles_t &b)
angles_t operator- (angles_t &a, angles_t &b)
angles_t operator- (angles_t &a, angles_t &b)
int operator== (angles_t &a, angles_t &b)
int operator== (angles_t &a, angles_t &b)
void toAngles (mat3_t &src, angles_t &dst)
void toAngles (quat_t &src, angles_t &dst)
void toAngles (idVec3_t &src, angles_t &dst)
void toAngles (mat3_t &src, angles_t &dst)
void toAngles (quat_t &src, angles_t &dst)
void toAngles (idVec3_t &src, angles_t &dst)


Constructor & Destructor Documentation

angles_t  )  [inline]
 

Definition at line 85 of file math_angles.h.

00085 {}

angles_t float  pitch,
float  yaw,
float  roll
[inline]
 

Definition at line 87 of file math_angles.h.

00087                                                               {
00088     this->pitch = pitch;
00089     this->yaw   = yaw;
00090     this->roll  = roll;
00091 }

angles_t const idVec3_t vec  )  [inline]
 

Definition at line 93 of file math_angles.h.

References pitch, roll, idVec3_t::x, idVec3_t::y, yaw, and idVec3_t::z.

00093                                                {
00094     this->pitch = vec.x;
00095     this->yaw   = vec.y;
00096     this->roll  = vec.z;
00097 }

angles_t  ) 
 

angles_t float  pitch,
float  yaw,
float  roll
 

angles_t const idVec3_t vec  ) 
 


Member Function Documentation

angles_t& Normalize180 void   ) 
 

angles_t & Normalize180 void   ) 
 

Definition at line 135 of file math_angles.cpp.

References Normalize360(), pitch, roll, and yaw.

00135                                        {
00136     Normalize360();
00137 
00138     if ( pitch > 180.0 ) {
00139         pitch -= 360.0;
00140     }
00141     
00142     if ( yaw > 180.0 ) {
00143         yaw  -= 360.0;
00144     }
00145 
00146     if ( roll > 180.0 ) {
00147         roll -= 360.0;
00148     }
00149     return *this;
00150 }

Here is the call graph for this function:

angles_t& Normalize360 void   ) 
 

angles_t & Normalize360 void   ) 
 

Definition at line 119 of file math_angles.cpp.

References pitch, roll, and yaw.

Referenced by Normalize180().

00119                                        {
00120     pitch   = (360.0 / 65536) * ( ( int )( pitch    * ( 65536 / 360.0 ) ) & 65535 );
00121     yaw     = (360.0 / 65536) * ( ( int )( yaw      * ( 65536 / 360.0 ) ) & 65535 );
00122     roll    = (360.0 / 65536) * ( ( int )( roll     * ( 65536 / 360.0 ) ) & 65535 );
00123 
00124     return *this;
00125 }

angles_t& operator *= float  a  ) 
 

angles_t & operator *= float  a  )  [inline]
 

Definition at line 171 of file math_angles.h.

References pitch, roll, and yaw.

00171                                                {
00172     pitch   *= a;
00173     yaw     *= a;
00174     roll    *= a;
00175 
00176     return *this;
00177 }

operator vec3_p  ) 
 

operator vec3_p  )  [inline]
 

Definition at line 109 of file math_angles.h.

00109                                        {
00110     return *( idVec3_t * )&pitch;
00111 }

angles_t& operator+= idVec3_t const &  a  ) 
 

angles_t& operator+= angles_t const &  a  ) 
 

angles_t & operator+= idVec3_t const &  a  )  [inline]
 

Definition at line 143 of file math_angles.h.

References a, pitch, roll, idVec3_t::x, idVec3_t::y, yaw, and idVec3_t::z.

00143                                                          {
00144     pitch   += a.x;
00145     yaw += a.y;
00146     roll    += a.z;
00147 
00148     return *this;
00149 }

angles_t & operator+= angles_t const &  a  )  [inline]
 

Definition at line 135 of file math_angles.h.

References a, pitch, roll, and yaw.

00135                                                          {
00136     pitch   += a.pitch;
00137     yaw     += a.yaw;
00138     roll    += a.roll;
00139 
00140     return *this;
00141 }

angles_t& operator-= angles_t a  ) 
 

angles_t & operator-= angles_t a  )  [inline]
 

Definition at line 155 of file math_angles.h.

References a, pitch, roll, and yaw.

00155                                                    {
00156     pitch   -= a.pitch;
00157     yaw     -= a.yaw;
00158     roll    -= a.roll;
00159 
00160     return *this;
00161 }

void operator= idVec3_t const &  a  ) 
 

void operator= angles_t const &  a  ) 
 

void operator= idVec3_t const &  a  )  [inline]
 

Definition at line 125 of file math_angles.h.

References a, pitch, roll, and yaw.

00125                                                    {
00126     pitch   = a[ 0 ];
00127     yaw     = a[ 1 ];
00128     roll    = a[ 2 ];
00129 }

void operator= angles_t const &  a  )  [inline]
 

Definition at line 119 of file math_angles.h.

References a, pitch, roll, and yaw.

00119                                                    {
00120     pitch   = a.pitch;
00121     yaw     = a.yaw;
00122     roll    = a.roll;
00123 }

float& operator[] int  index  ) 
 

float operator[] int  index  )  const
 

float & operator[] int  index  )  [inline]
 

Definition at line 104 of file math_angles.h.

References assert.

00104                                               {
00105     assert( ( index >= 0 ) && ( index < 3 ) );
00106     return ( &pitch )[ index ];
00107 }

float operator[] int  index  )  const [inline]
 

Definition at line 99 of file math_angles.h.

References assert.

00099                                                    {
00100     assert( ( index >= 0 ) && ( index < 3 ) );
00101     return ( &pitch )[ index ];
00102 }

void set float  pitch,
float  yaw,
float  roll
 

void set float  pitch,
float  yaw,
float  roll
[inline]
 

Definition at line 113 of file math_angles.h.

00113                                                               {
00114     this->pitch = pitch;
00115     this->yaw   = yaw;
00116     this->roll  = roll;
00117 }

idVec3_t toForward void   ) 
 

idVec3_t toForward void   ) 
 

Definition at line 97 of file math_angles.cpp.

References cos(), cp, M_PI, pitch, sin(), and yaw.

00097                                    {
00098     float           angle;
00099     static float    sp, sy, cp, cy; // static to help MS compiler fp bugs
00100     
00101     angle = yaw * ( M_PI * 2 / 360 );
00102     sy = sin( angle );
00103     cy = cos( angle );
00104 
00105     angle = pitch * ( M_PI * 2 / 360 );
00106     sp = sin( angle );
00107     cp = cos( angle );
00108 
00109     return idVec3_t( cp * cy, cp * sy, -sp );
00110 }

Here is the call graph for this function:

void toVectors idVec3_t forward,
idVec3_t right = NULL,
idVec3_t up = NULL
 

void toVectors idVec3_t forward,
idVec3_t right = NULL,
idVec3_t up = NULL
 

Definition at line 68 of file math_angles.cpp.

References cos(), cp, M_PI, pitch, right, roll, idVec3_t::set(), sin(), up, and yaw.

00068                                                                            {
00069     float           angle;
00070     static float    sr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs
00071     
00072     angle = yaw * ( M_PI * 2 / 360 );
00073     sy = sin( angle );
00074     cy = cos( angle );
00075 
00076     angle = pitch * ( M_PI * 2 / 360 );
00077     sp = sin( angle );
00078     cp = cos( angle );
00079 
00080     angle = roll * ( M_PI * 2 / 360 );
00081     sr = sin( angle );
00082     cr = cos( angle );
00083 
00084     if ( forward ) {
00085         forward->set( cp * cy, cp * sy, -sp );
00086     }
00087 
00088     if ( right ) {
00089         right->set( -sr * sp * cy + cr * sy, -sr * sp * sy + -cr * cy, -sr * cp );
00090     }
00091 
00092     if ( up ) {
00093         up->set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );
00094     }
00095 }

Here is the call graph for this function:

angles_t& Zero void   ) 
 

angles_t & Zero void   )  [inline]
 

Definition at line 187 of file math_angles.h.

References pitch, roll, and yaw.

00187                                       {
00188     pitch   = 0.0f;
00189     yaw     = 0.0f;
00190     roll    = 0.0f;
00191 
00192     return *this;
00193 }


Friends And Related Function Documentation

angles_t operator * float  a,
const angles_t b
[friend]
 

Definition at line 167 of file math_angles.h.

00167                                                         {
00168     return angles_t( a * b.pitch, a * b.yaw, a * b.roll );
00169 }

angles_t operator * const angles_t a,
float  b
[friend]
 

Definition at line 163 of file math_angles.h.

00163                                                         {
00164     return angles_t( a.pitch * b, a.yaw * b, a.roll * b );
00165 }

angles_t operator * float  a,
const angles_t b
[friend]
 

Definition at line 167 of file math_angles.h.

00167                                                         {
00168     return angles_t( a * b.pitch, a * b.yaw, a * b.roll );
00169 }

angles_t operator * const angles_t a,
float  b
[friend]
 

Definition at line 163 of file math_angles.h.

00163                                                         {
00164     return angles_t( a.pitch * b, a.yaw * b, a.roll * b );
00165 }

int operator!= angles_t a,
angles_t b
[friend]
 

Definition at line 183 of file math_angles.h.

00183                                                   {
00184     return ( ( a.pitch != b.pitch ) || ( a.yaw != b.yaw ) || ( a.roll != b.roll ) );
00185 }

int operator!= angles_t a,
angles_t b
[friend]
 

Definition at line 183 of file math_angles.h.

00183                                                   {
00184     return ( ( a.pitch != b.pitch ) || ( a.yaw != b.yaw ) || ( a.roll != b.roll ) );
00185 }

angles_t operator+ const angles_t a,
const angles_t b
[friend]
 

Definition at line 131 of file math_angles.h.

00131                                                                   {
00132     return angles_t( a.pitch + b.pitch, a.yaw + b.yaw, a.roll + b.roll );
00133 }

angles_t operator+ const angles_t a,
const angles_t b
[friend]
 

Definition at line 131 of file math_angles.h.

00131                                                                   {
00132     return angles_t( a.pitch + b.pitch, a.yaw + b.yaw, a.roll + b.roll );
00133 }

angles_t operator- angles_t a,
angles_t b
[friend]
 

Definition at line 151 of file math_angles.h.

00151                                                       {
00152     return angles_t( a.pitch - b.pitch, a.yaw - b.yaw, a.roll - b.roll );
00153 }

angles_t operator- angles_t a,
angles_t b
[friend]
 

Definition at line 151 of file math_angles.h.

00151                                                       {
00152     return angles_t( a.pitch - b.pitch, a.yaw - b.yaw, a.roll - b.roll );
00153 }

int operator== angles_t a,
angles_t b
[friend]
 

Definition at line 179 of file math_angles.h.

00179                                                   {
00180     return ( ( a.pitch == b.pitch ) && ( a.yaw == b.yaw ) && ( a.roll == b.roll ) );
00181 }

int operator== angles_t a,
angles_t b
[friend]
 

Definition at line 179 of file math_angles.h.

00179                                                   {
00180     return ( ( a.pitch == b.pitch ) && ( a.yaw == b.yaw ) && ( a.roll == b.roll ) );
00181 }

void toAngles mat3_t src,
angles_t dst
[friend]
 

Definition at line 27 of file math_angles.cpp.

00027                                             {
00028     double      theta;
00029     double      cp;
00030     double      sp;
00031 
00032     sp = src[ 0 ][ 2 ];
00033 
00034     // cap off our sin value so that we don't get any NANs
00035     if ( sp > 1.0 ) {
00036         sp = 1.0;
00037     } else if ( sp < -1.0 ) {
00038         sp = -1.0;
00039     }
00040 
00041     theta = -asin( sp );
00042     cp = cos( theta );
00043 
00044     if ( cp > 8192 * FLT_EPSILON ) {
00045         dst.pitch   = theta * 180 / M_PI;
00046         dst.yaw     = atan2( src[ 0 ][ 1 ], src[ 0 ][ 0 ] ) * 180 / M_PI;
00047         dst.roll    = atan2( src[ 1 ][ 2 ], src[ 2 ][ 2 ] ) * 180 / M_PI;
00048     } else {
00049         dst.pitch   = theta * 180 / M_PI;
00050         dst.yaw     = -atan2( src[ 1 ][ 0 ], src[ 1 ][ 1 ] ) * 180 / M_PI;
00051         dst.roll    = 0;
00052     }
00053 }

void toAngles quat_t src,
angles_t dst
[friend]
 

Definition at line 55 of file math_angles.cpp.

00055                                             {
00056     mat3_t temp;
00057 
00058     toMatrix( src, temp );
00059     toAngles( temp, dst );
00060 }

void toAngles idVec3_t src,
angles_t dst
[friend]
 

Definition at line 62 of file math_angles.cpp.

00062                                               {
00063     dst.pitch   = src[ 0 ];
00064     dst.yaw     = src[ 1 ];
00065     dst.roll    = src[ 2 ];
00066 }

void toAngles mat3_t src,
angles_t dst
[friend]
 

Definition at line 27 of file math_angles.cpp.

00027                                             {
00028     double      theta;
00029     double      cp;
00030     double      sp;
00031 
00032     sp = src[ 0 ][ 2 ];
00033 
00034     // cap off our sin value so that we don't get any NANs
00035     if ( sp > 1.0 ) {
00036         sp = 1.0;
00037     } else if ( sp < -1.0 ) {
00038         sp = -1.0;
00039     }
00040 
00041     theta = -asin( sp );
00042     cp = cos( theta );
00043 
00044     if ( cp > 8192 * FLT_EPSILON ) {
00045         dst.pitch   = theta * 180 / M_PI;
00046         dst.yaw     = atan2( src[ 0 ][ 1 ], src[ 0 ][ 0 ] ) * 180 / M_PI;
00047         dst.roll    = atan2( src[ 1 ][ 2 ], src[ 2 ][ 2 ] ) * 180 / M_PI;
00048     } else {
00049         dst.pitch   = theta * 180 / M_PI;
00050         dst.yaw     = -atan2( src[ 1 ][ 0 ], src[ 1 ][ 1 ] ) * 180 / M_PI;
00051         dst.roll    = 0;
00052     }
00053 }

void toAngles quat_t src,
angles_t dst
[friend]
 

Definition at line 55 of file math_angles.cpp.

00055                                             {
00056     mat3_t temp;
00057 
00058     toMatrix( src, temp );
00059     toAngles( temp, dst );
00060 }

void toAngles idVec3_t src,
angles_t dst
[friend]
 

Definition at line 62 of file math_angles.cpp.

00062                                               {
00063     dst.pitch   = src[ 0 ];
00064     dst.yaw     = src[ 1 ];
00065     dst.roll    = src[ 2 ];
00066 }


Field Documentation

float pitch
 

Definition at line 37 of file math_angles.h.

Referenced by angles_t(), Normalize180(), Normalize360(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator=(), operator==(), toAngles(), toForward(), toVectors(), and Zero().

float roll
 

Definition at line 39 of file math_angles.h.

Referenced by angles_t(), Normalize180(), Normalize360(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator=(), operator==(), toAngles(), toVectors(), and Zero().

float yaw
 

Definition at line 38 of file math_angles.h.

Referenced by angles_t(), Normalize180(), Normalize360(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator=(), operator==(), toAngles(), toForward(), toVectors(), and Zero().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 18:52:17 2005 for Quake III Arena by  doxygen 1.3.9.1