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

math_angles.cpp File Reference

#include "q_shared.h"
#include <float.h>

Include dependency graph for math_angles.cpp:

Include dependency graph

Go to the source code of this file.

Functions

void toAngles (idVec3_t &src, angles_t &dst)
void toAngles (quat_t &src, angles_t &dst)
void toAngles (mat3_t &src, angles_t &dst)

Variables

angles_t ang_zero (0.0f, 0.0f, 0.0f)


Function Documentation

void toAngles idVec3_t src,
angles_t dst
 

Definition at line 62 of file math_angles.cpp.

References angles_t::pitch, angles_t::roll, src, and angles_t::yaw.

Referenced by toAngles().

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

void toAngles quat_t src,
angles_t dst
 

Definition at line 55 of file math_angles.cpp.

References src, toAngles(), and toMatrix().

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

Here is the call graph for this function:

void toAngles mat3_t src,
angles_t dst
 

Definition at line 27 of file math_angles.cpp.

References asin(), atan2(), cos(), cp, angles_t::pitch, angles_t::roll, src, and angles_t::yaw.

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 }

Here is the call graph for this function:


Variable Documentation

angles_t ang_zero(0.0f, 0.0f, 0.0f)
 


Generated on Thu Aug 25 15:33:47 2005 for Quake III Arena by  doxygen 1.3.9.1