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

idVec3_t Class Reference

#include <math_vector.h>

Inheritance diagram for idVec3_t:

Inheritance graph
[legend]

Public Member Functions

idVec3_tCross (const idVec3_t &a, const idVec3_t &b)
idVec3_t Cross (const idVec3_t &a) const
idVec3_tCross (const idVec3_t &a, const idVec3_t &b)
idVec3_t Cross (const idVec3_t &a) const
 idVec3_t (const float x, const float y, const float z)
 idVec3_t ()
 idVec3_t (const float x, const float y, const float z)
 idVec3_t ()
float Length (void) const
float Length (void) const
float Normalize (void)
float Normalize (void)
idVec3_t operator * (const float a) const
float operator * (const idVec3_t &a) const
idVec3_t operator * (const float a) const
float operator * (const idVec3_t &a) const
idVec3_toperator *= (const float a)
idVec3_toperator *= (const float a)
 operator float * ()
 operator float * ()
int operator!= (const idVec3_t &a) const
int operator!= (const idVec3_t &a) const
idVec3_t operator+ (const idVec3_t &a) const
idVec3_t operator+ (const idVec3_t &a) const
idVec3_toperator+= (const idVec3_t &a)
idVec3_toperator+= (const idVec3_t &a)
idVec3_t operator- (const idVec3_t &a) const
idVec3_t operator- () const
idVec3_t operator- (const idVec3_t &a) const
idVec3_t operator- () const
idVec3_toperator-= (const idVec3_t &a)
idVec3_toperator-= (const idVec3_t &a)
idVec3_toperator= (const idVec3_t &a)
idVec3_toperator= (const idVec3_t &a)
int operator== (const idVec3_t &a) const
int operator== (const idVec3_t &a) const
float & operator[] (const int index)
float operator[] (const int index) const
float & operator[] (const int index)
float operator[] (const int index) const
void set (const float x, const float y, const float z)
void set (const float x, const float y, const float z)
void Snap (void)
void Snap (void)
void SnapTowards (const idVec3_t &to)
void SnapTowards (const idVec3_t &to)
char * string (void)
char * string (void)
angles_t toAngles (void)
angles_t toAngles (void)
float toPitch (void)
float toPitch (void)
float toYaw (void)
float toYaw (void)
void Zero (void)
void Zero (void)

Data Fields

float x
float y
float z

Friends

idVec3_t LerpVector (const idVec3_t &w1, const idVec3_t &w2, const float t)
idVec3_t LerpVector (const idVec3_t &w1, const idVec3_t &w2, const float t)
idVec3_t operator * (float a, idVec3_t b)
idVec3_t operator * (float a, idVec3_t b)

Constructor & Destructor Documentation

idVec3_t  )  [inline]
 

Definition at line 134 of file math_vector.h.

Referenced by Cross(), operator *(), operator+(), and operator-().

00134 {};

ID_INLINE idVec3_t const float  x,
const float  y,
const float  z
 

Definition at line 185 of file math_vector.h.

References ID_INLINE, x, y, and z.

00185                                                                           {
00186     this->x = x;
00187     this->y = y;
00188     this->z = z;
00189 #ifdef  FAT_VEC3
00190     this->dist = 0.0f;
00191 #endif
00192 }

idVec3_t  )  [inline]
 

Definition at line 132 of file math_vector.h.

00132 {};

idVec3_t const float  x,
const float  y,
const float  z
 


Member Function Documentation

idVec3_t& Cross const idVec3_t a,
const idVec3_t b
 

idVec3_t Cross const idVec3_t a  )  const
 

ID_INLINE idVec3_t & Cross const idVec3_t a,
const idVec3_t b
 

Definition at line 304 of file math_vector.h.

References a, b, ID_INLINE, x, y, and z.

00304                                                                           {
00305     x = a.y * b.z - a.z * b.y;
00306     y = a.z * b.x - a.x * b.z;
00307     z = a.x * b.y - a.y * b.x;
00308 
00309     return *this;
00310 }

ID_INLINE idVec3_t Cross const idVec3_t a  )  const
 

Definition at line 300 of file math_vector.h.

References a, ID_INLINE, idVec3_t(), x, x, y, z, and z.

Referenced by mat3_t::OrthoNormalize().

00300                                                             {
00301     return idVec3_t( y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x );
00302 }

Here is the call graph for this function:

float Length void   )  const
 

ID_INLINE float Length void   )  const
 

Definition at line 312 of file math_vector.h.

References ID_INLINE, idSqrt(), length(), x, y, and z.

Referenced by idInterpolatedPosition::getPosition(), idSplineList::initPosition(), Normalize(), idPointListInterface::selectPointByRay(), idInterpolatedPosition::start(), and idSplineList::totalDistance().

00312                                              {
00313     float length;
00314     
00315     length = x * x + y * y + z * z;
00316     return ( float )idSqrt( length );
00317 }

Here is the call graph for this function:

float Normalize void   ) 
 

ID_INLINE float Normalize void   ) 
 

Definition at line 319 of file math_vector.h.

References ID_INLINE, Length(), length(), x, y, and z.

Referenced by idCameraDef::getCameraInfo(), and mat3_t::OrthoNormalize().

00319                                           {
00320     float length;
00321     float ilength;
00322 
00323     length = this->Length();
00324     if ( length ) {
00325         ilength = 1.0f / length;
00326         x *= ilength;
00327         y *= ilength;
00328         z *= ilength;
00329     }
00330         
00331     return length;
00332 }

Here is the call graph for this function:

idVec3_t operator * const float  a  )  const
 

float operator * const idVec3_t a  )  const
 

ID_INLINE idVec3_t operator * const float  a  )  const
 

Definition at line 232 of file math_vector.h.

References a, ID_INLINE, idVec3_t(), x, y, and z.

00232                                                             {
00233     return idVec3_t( x * a, y * a, z * a );
00234 }

Here is the call graph for this function:

ID_INLINE float operator * const idVec3_t a  )  const
 

Definition at line 228 of file math_vector.h.

References a, ID_INLINE, x, y, and z.

00228                                                              {
00229     return x * a.x + y * a.y + z * a.z;
00230 }

idVec3_t& operator *= const float  a  ) 
 

ID_INLINE idVec3_t & operator *= const float  a  ) 
 

Definition at line 260 of file math_vector.h.

References ID_INLINE, x, y, and z.

00260                                                         {
00261     x *= a;
00262     y *= a;
00263     z *= a;
00264 
00265     return *this;
00266 }

operator float *  ) 
 

ID_INLINE operator float *  ) 
 

Definition at line 202 of file math_vector.h.

References ID_INLINE.

00202                                            {
00203     return &x;
00204 }

int operator!= const idVec3_t a  )  const
 

ID_INLINE int operator!= const idVec3_t a  )  const
 

Definition at line 284 of file math_vector.h.

References a, ID_INLINE, Q_fabs(), x, y, and z.

00284                                                             {
00285     if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {
00286         return true;
00287     }
00288             
00289     if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {
00290         return true;
00291     }
00292 
00293     if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {
00294         return true;
00295     }
00296 
00297     return false;
00298 }

Here is the call graph for this function:

idVec3_t operator+ const idVec3_t a  )  const
 

ID_INLINE idVec3_t operator+ const idVec3_t a  )  const
 

Definition at line 240 of file math_vector.h.

References a, ID_INLINE, idVec3_t(), x, y, and z.

00240                                                                 {
00241     return idVec3_t( x + a.x, y + a.y, z + a.z );
00242 }

Here is the call graph for this function:

idVec3_t& operator+= const idVec3_t a  ) 
 

ID_INLINE idVec3_t & operator+= const idVec3_t a  ) 
 

Definition at line 244 of file math_vector.h.

References a, ID_INLINE, x, y, and z.

00244                                                             {
00245     x += a.x;
00246     y += a.y;
00247     z += a.z;
00248 
00249     return *this;
00250 }

idVec3_t operator- const idVec3_t a  )  const
 

idVec3_t operator-  )  const
 

ID_INLINE idVec3_t operator- const idVec3_t a  )  const
 

Definition at line 224 of file math_vector.h.

References a, ID_INLINE, idVec3_t(), x, y, and z.

00224                                                                 {
00225     return idVec3_t( x - a.x, y - a.y, z - a.z );
00226 }

Here is the call graph for this function:

ID_INLINE idVec3_t operator-  )  const
 

Definition at line 206 of file math_vector.h.

References ID_INLINE, idVec3_t(), x, y, and z.

00206                                              {
00207     return idVec3_t( -x, -y, -z );
00208 }

Here is the call graph for this function:

idVec3_t& operator-= const idVec3_t a  ) 
 

ID_INLINE idVec3_t & operator-= const idVec3_t a  ) 
 

Definition at line 252 of file math_vector.h.

References a, ID_INLINE, x, y, and z.

00252                                                             {
00253     x -= a.x;
00254     y -= a.y;
00255     z -= a.z;
00256 
00257     return *this;
00258 }

idVec3_t& operator= const idVec3_t a  ) 
 

ID_INLINE idVec3_t & operator= const idVec3_t a  ) 
 

Definition at line 210 of file math_vector.h.

References a, ID_INLINE, x, y, and z.

00210                                                            { 
00211     x = a.x;
00212     y = a.y;
00213     z = a.z;
00214     
00215     return *this;
00216 }

int operator== const idVec3_t a  )  const
 

ID_INLINE int operator== const idVec3_t a  )  const
 

Definition at line 268 of file math_vector.h.

References a, ID_INLINE, Q_fabs(), x, y, and z.

00268                                                             {
00269     if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {
00270         return false;
00271     }
00272             
00273     if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {
00274         return false;
00275     }
00276 
00277     if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {
00278         return false;
00279     }
00280 
00281     return true;
00282 }

Here is the call graph for this function:

float& operator[] const int  index  ) 
 

Reimplemented in vec4_t, idVec5_t, vec4_t, and idVec5_t.

float operator[] const int  index  )  const
 

Reimplemented in vec4_t, idVec5_t, vec4_t, and idVec5_t.

ID_INLINE float & operator[] const int  index  ) 
 

Reimplemented in vec4_t, idVec5_t, vec4_t, and idVec5_t.

Definition at line 198 of file math_vector.h.

References ID_INLINE.

00198                                                        {
00199     return ( &x )[ index ];
00200 }

ID_INLINE float operator[] const int  index  )  const
 

Reimplemented in vec4_t, idVec5_t, vec4_t, and idVec5_t.

Definition at line 194 of file math_vector.h.

References ID_INLINE.

00194                                                             {
00195     return ( &x )[ index ];
00196 }

void set const float  x,
const float  y,
const float  z
 

ID_INLINE void set const float  x,
const float  y,
const float  z
 

Definition at line 218 of file math_vector.h.

References ID_INLINE, x, y, and z.

Referenced by idInterpolatedPosition::addPoint(), idFixedPosition::addPoint(), idSplineList::clear(), mat3_t::Clear(), and angles_t::toVectors().

00218                                                                           {
00219     this->x = x;
00220     this->y = y;
00221     this->z = z;
00222 }

void Snap void   ) 
 

ID_INLINE void Snap void   ) 
 

Definition at line 340 of file math_vector.h.

References ID_INLINE, x, y, and z.

Referenced by idSplineList::setSelectedPoint().

00340                                     {
00341     x = float( int( x ) );
00342     y = float( int( y ) );
00343     z = float( int( z ) );
00344 }

void SnapTowards const idVec3_t to  ) 
 

ID_INLINE void SnapTowards const idVec3_t to  ) 
 

Definition at line 356 of file math_vector.h.

References ID_INLINE, x, y, and z.

00356                                                          {
00357     if ( to.x <= x ) {
00358         x = float( int( x ) );
00359     } else {
00360         x = float( int( x ) + 1 );
00361     }
00362 
00363     if ( to.y <= y ) {
00364         y = float( int( y ) );
00365     } else {
00366         y = float( int( y ) + 1 );
00367     }
00368 
00369     if ( to.z <= z ) {
00370         z = float( int( z ) );
00371     } else {
00372         z = float( int( z ) + 1 );
00373     }
00374 }

char* string void   ) 
 

char * string void   ) 
 

Definition at line 132 of file math_vector.cpp.

References s, sprintf(), x, y, and z.

Referenced by CG_DrawBlueName(), and CG_DrawRedName().

00132                              {
00133     static  int     index = 0;
00134     static  char    str[ 8 ][ 36 ];
00135     char    *s;
00136 
00137     // use an array so that multiple toString's won't collide
00138     s = str[ index ];
00139     index = (index + 1)&7;
00140 
00141     sprintf( s, "%.2f %.2f %.2f", x, y, z );
00142 
00143     return s;
00144 }

Here is the call graph for this function:

angles_t toAngles void   ) 
 

angles_t toAngles void   ) 
 

float toPitch void   ) 
 

float toPitch void   ) 
 

Definition at line 56 of file math_vector.cpp.

References atan2(), idSqrt(), x, y, and z.

00056                               {
00057     float   forward;
00058     float   pitch;
00059     
00060     if ( ( x == 0 ) && ( y == 0 ) ) {
00061         if ( z > 0 ) {
00062             pitch = 90;
00063         } else {
00064             pitch = 270;
00065         }
00066     } else {
00067         forward = ( float )idSqrt( x * x + y * y );
00068         pitch = atan2( z, forward ) * 180 / M_PI;
00069         if ( pitch < 0 ) {
00070             pitch += 360;
00071         }
00072     }
00073 
00074     return pitch;
00075 }

Here is the call graph for this function:

float toYaw void   ) 
 

float toYaw void   ) 
 

Definition at line 41 of file math_vector.cpp.

References atan2(), x, and y.

00041                             {
00042     float yaw;
00043     
00044     if ( ( y == 0 ) && ( x == 0 ) ) {
00045         yaw = 0;
00046     } else {
00047         yaw = atan2( y, x ) * 180 / M_PI;
00048         if ( yaw < 0 ) {
00049             yaw += 360;
00050         }
00051     }
00052 
00053     return yaw;
00054 }

Here is the call graph for this function:

void Zero void   ) 
 

ID_INLINE void Zero void   ) 
 

Definition at line 334 of file math_vector.h.

References ID_INLINE, x, y, and z.

Referenced by idInterpolatedPosition::init(), and idFixedPosition::init().

00334                                     {
00335     x = 0.0f;
00336     y = 0.0f;
00337     z = 0.0f;
00338 }


Friends And Related Function Documentation

idVec3_t LerpVector const idVec3_t w1,
const idVec3_t w2,
const float  t
[friend]
 

idVec3_t LerpVector const idVec3_t w1,
const idVec3_t w2,
const float  t
[friend]
 

idVec3_t operator * float  a,
idVec3_t  b
[friend]
 

Definition at line 236 of file math_vector.h.

00236                                                                 {
00237     return idVec3_t( b.x * a, b.y * a, b.z * a );
00238 }

idVec3_t operator * float  a,
idVec3_t  b
[friend]
 

Definition at line 236 of file math_vector.h.

00236                                                                 {
00237     return idVec3_t( b.x * a, b.y * a, b.z * a );
00238 }


Field Documentation

float x
 

Definition at line 126 of file math_vector.h.

Referenced by angles_t::angles_t(), Cross(), glLabeledPoint(), mat3_t::Identity(), Length(), mat3_t::mat3_t(), Normalize(), operator *(), operator *(), mat3_t::operator *(), operator *=(), mat3_t::operator *=(), operator!=(), operator+(), operator+=(), mat3_t::operator+=(), angles_t::operator+=(), operator-(), operator-=(), mat3_t::operator-=(), operator=(), operator==(), mat3_t::ProjectVector(), Snap(), SnapTowards(), string(), toPitch(), toYaw(), idInterpolatedPosition::write(), idFixedPosition::write(), and Zero().

float y
 

Definition at line 126 of file math_vector.h.

Referenced by angles_t::angles_t(), Cross(), glLabeledPoint(), mat3_t::Identity(), Length(), mat3_t::mat3_t(), Normalize(), operator *(), operator *(), mat3_t::operator *(), operator *=(), mat3_t::operator *=(), operator!=(), operator+(), operator+=(), mat3_t::operator+=(), angles_t::operator+=(), operator-(), operator-=(), mat3_t::operator-=(), operator=(), operator==(), mat3_t::ProjectVector(), Snap(), SnapTowards(), string(), toPitch(), toYaw(), idInterpolatedPosition::write(), idFixedPosition::write(), and Zero().

float z
 

Definition at line 126 of file math_vector.h.

Referenced by angles_t::angles_t(), Cross(), glLabeledPoint(), mat3_t::Identity(), Length(), mat3_t::mat3_t(), Normalize(), operator *(), operator *(), mat3_t::operator *(), operator *=(), mat3_t::operator *=(), operator!=(), operator+(), operator+=(), mat3_t::operator+=(), angles_t::operator+=(), operator-(), operator-=(), mat3_t::operator-=(), operator=(), operator==(), mat3_t::ProjectVector(), Snap(), SnapTowards(), string(), toPitch(), idInterpolatedPosition::write(), idFixedPosition::write(), and Zero().


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