NLMISC::CQuat Class Reference

#include <quat.h>

Inheritance diagram for NLMISC::CQuat:

NLMISC::CQuatT< float >

Detailed Description

A float quaternion.
Author:
Antoine Viau.

Nevrax France

Date:
2000

Definition at line 496 of file quat.h.

Public Member Functions

CQuatT conjugate () const
 return the conjugate of this quaternion.

bool equal (const CQuatT &a, float epsilon=1E-6f) const
CQuatT exp ()
 compute quaternion exponent.

float getAngle () const
 Return the equivalent angle of this quaternion. (in radian).

CAngleAxis getAngleAxis () const
 Return the equivalent Unit AngleAxis of this quaternion.

CVector getAxis () const
 Return the equivalent Unit axis of this quaternion.

void identity ()
void invert ()
 Invert this quaternion. If normalized, conjugate is faster and does same thing.

CQuatT inverted () const
 return the quaternion inverted.

bool isIdentity () const
CQuatT log ()
 compute logn quaternion.

void makeClosest (const CQuatT &o)
 ensure that *this and q are on same side of hypersphere, ie dotProduct(*this,q) is >0, modifying this if necessary.

float norm () const
 return the norm of the 4D vector.

void normalize ()
 Normalize the quaternion.

CQuatT normed () const
 Return the quaternion normalized.

CQuatT operator * (const CQuatT &) const
 Quaternion multiplication/composition.

CQuatT operator * (floatf) const
CQuatToperator *= (const CQuatT &)
CQuatToperator *= (floatf)
CQuatT operator+ () const
CQuatT operator+ (const CQuatT &o) const
CQuatToperator+= (const CQuatT &o)
CQuatT operator- () const
CQuatT operator- (const CQuatT &o) const
CQuatToperator-= (const CQuatT &o)
CQuatT operator/ (floatf) const
CQuatToperator/= (floatf)
bool operator== (const CQuatT &a) const
void serial (IStream &f)
 serial.

void set (floatX, floatY, floatZ, floatW)
void setAngleAxis (const CAngleAxis &angAxis)
 Build a UNIT quaternion from an AngleAxis.

void setAngleAxis (const CVector &axis, float angle)
 Build a UNIT quaternion from an AngleAxis.

float sqrnorm () const
 return the square of the norm of the 4D vector.

Object
 CQuat (const CAngleAxis &aa)
 ctor of a UNIT quaternion, from an angle axis.

 CQuat (const CVector &axis, float angle)
 ctor of a UNIT quaternion, from an angle axis.

 CQuat (float X, float Y, float Z, float W)
 ctor of a UNIT quaternion, from an angle axis.

 CQuat ()
 ctor of a UNIT quaternion, from an angle axis.

 CQuat (const CQuatT< float > &o)
 ctor of a UNIT quaternion, from an angle axis.

CQuatoperator= (const CQuatT< float > &o)
 ctor of a UNIT quaternion, from an angle axis.


Static Public Member Functions

float dotProduct (const CQuatT< float > &q0, const CQuatT< float > &q1)
 Return the dotProduct of 2 quaternions.

CQuatT lnDif (const CQuatT &q0, const CQuatT &q1)
 compute lnDiff of q0.inverted()*q1.

CQuatT slerp (const CQuatT< float > &q0, const CQuatT< float > &q1, float t)
CQuatT squad (const CQuatT< float > &q0, const CQuatT< float > &tgtQ0, const CQuatT< float > &tgtQ1, const CQuatT< float > &q1, float t)
CQuatT squadrev (const CAngleAxis &rot, const CQuatT< float > &q0, const CQuatT< float > &tgtQ0, const CQuatT< float > &tgtQ1, const CQuatT< float > &q1, float t)

Data Fields

float w
float x
float y
float z

Static Public Attributes

const CQuat Identity


Constructor & Destructor Documentation

NLMISC::CQuat::CQuat const CQuatT< float > &  o  )  [inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 504 of file quat.h.

00504 : CQuatT<float>(o) {}

NLMISC::CQuat::CQuat  )  [inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 505 of file quat.h.

00505 {}

NLMISC::CQuat::CQuat float  X,
float  Y,
float  Z,
float  W
[inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 506 of file quat.h.

00506 : CQuatT<float>(X,Y,Z,W) {}

NLMISC::CQuat::CQuat const CVector axis,
float  angle
[inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 508 of file quat.h.

00508 : CQuatT<float>(axis, angle) {}

NLMISC::CQuat::CQuat const CAngleAxis aa  )  [inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 510 of file quat.h.

00510 : CQuatT<float>(aa) {}


Member Function Documentation

CQuatT NLMISC::CQuatT< float >::conjugate  )  const [inline, inherited]
 

return the conjugate of this quaternion.

Definition at line 139 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), w, x, y, and z.

Referenced by NL3D::CTargetAnimCtrl::execute(), and NL3D::CTargetAnimCtrl::getCurrentLSRotationFromBone().

00139 {return CQuatT(-x, -y, -z, w);}

float NLMISC::CQuatT< float >::dotProduct const CQuatT< float > &  q0,
const CQuatT< float > &  q1
[static, inherited]
 

Return the dotProduct of 2 quaternions.

bool NLMISC::CQuatT< float >::equal const CQuatT< float > &  a,
float  epsilon = 1E-6f
const [inherited]
 

CQuatT NLMISC::CQuatT< float >::exp  )  [inherited]
 

compute quaternion exponent.

float NLMISC::CQuatT< float >::getAngle  )  const [inline, inherited]
 

Return the equivalent angle of this quaternion. (in radian).

Definition at line 148 of file quat.h.

References NLMISC::CQuatT< T >::norm(), and w.

Referenced by NL3D::CTargetAnimCtrl::execute().

00148 {return (float)(2*acos(w/norm()));}

CAngleAxis NLMISC::CQuatT< float >::getAngleAxis  )  const [inline, inherited]
 

Return the equivalent Unit AngleAxis of this quaternion.

Definition at line 150 of file quat.h.

References NLMISC::CQuatT< T >::getAngle(), and NLMISC::CQuatT< T >::getAxis().

Referenced by NL3D::CTargetAnimCtrl::execute().

00150 {return CAngleAxis(getAxis(), getAngle());}

CVector NLMISC::CQuatT< float >::getAxis void   )  const [inline, inherited]
 

Return the equivalent Unit axis of this quaternion.

Definition at line 146 of file quat.h.

References NLMISC::CVector::normed(), x, y, and z.

00146 {CVector ret((float)x,(float)y,(float)z); return ret.normed();}

void NLMISC::CQuatT< float >::identity  )  [inline, inherited]
 

Definition at line 102 of file quat.h.

References w, x, y, and z.

00102 {x = y = z = 0.0f ;     w = 1.0f; }

void NLMISC::CQuatT< float >::invert  )  [inherited]
 

Invert this quaternion. If normalized, conjugate is faster and does same thing.

CQuatT NLMISC::CQuatT< float >::inverted  )  const [inline, inherited]
 

return the quaternion inverted.

Definition at line 137 of file quat.h.

References NLMISC::CQuatT< T >::invert().

00137 {CQuatT ret= *this; ret.invert(); return ret;}

bool NLMISC::CQuatT< float >::isIdentity  )  const [inline, inherited]
 

Definition at line 103 of file quat.h.

References w, x, y, and z.

Referenced by NLMISC::CMatrix::setRot().

00103 {return (x==0.0f && y==0.0f && z==0.0f && w==1.0f);}

CQuatT NLMISC::CQuatT< float >::lnDif const CQuatT< float > &  q0,
const CQuatT< float > &  q1
[static, inherited]
 

compute lnDiff of q0.inverted()*q1.

CQuatT NLMISC::CQuatT< float >::log  )  [inherited]
 

compute logn quaternion.

void NLMISC::CQuatT< float >::makeClosest const CQuatT< float > &  o  )  [inherited]
 

ensure that *this and q are on same side of hypersphere, ie dotProduct(*this,q) is >0, modifying this if necessary.

Referenced by NL3D::CTargetAnimCtrl::execute(), NL3D::CTargetAnimCtrl::getCurrentLSRotationFromBone(), and NL3D::CAnimationOptimizer::sampleQuatTrack().

float NLMISC::CQuatT< float >::norm  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 121 of file quat.h.

References NLMISC::CQuatT< T >::sqrnorm().

00121 {return (T)sqrt(sqrnorm());}

void NLMISC::CQuatT< float >::normalize  )  [inherited]
 

Normalize the quaternion.

Referenced by NL3D::CAnimationOptimizer::sampleQuatTrack().

CQuatT NLMISC::CQuatT< float >::normed  )  const [inline, inherited]
 

Return the quaternion normalized.

Definition at line 125 of file quat.h.

References NLMISC::CQuatT< T >::normalize().

00125 {CQuatT ret= *this; ret.normalize(); return ret;}

CQuatT NLMISC::CQuatT< float >::operator * const CQuatT< float > &   )  const [inherited]
 

Quaternion multiplication/composition.

CQuatT NLMISC::CQuatT< float >::operator * float   f  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 114 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), w, x, y, and z.

00114 {return CQuatT(x*f,y*f,z*f,w*f);}

CQuatT& NLMISC::CQuatT< float >::operator *= const CQuatT< float > &   )  [inherited]
 

return the conjugate of this quaternion.

CQuatT& NLMISC::CQuatT< float >::operator *= float   f  )  [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 110 of file quat.h.

References w, x, y, and z.

00110 {x*=f;y*=f;z*=f;w*=f; return *this;}

CQuatT NLMISC::CQuatT< float >::operator+  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 117 of file quat.h.

00117 {return *this; }

CQuatT NLMISC::CQuatT< float >::operator+ const CQuatT< float > &  o  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 112 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00112 {return CQuatT(x+o.x,y+o.y,z+o.z,w+o.w);}

CQuatT& NLMISC::CQuatT< float >::operator+= const CQuatT< float > &  o  )  [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 108 of file quat.h.

References NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00108 {x+=o.x; y+=o.y; z+=o.z; w+=o.w; return *this;}

CQuatT NLMISC::CQuatT< float >::operator-  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 116 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), w, x, y, and z.

00116 {return(CQuatT(-x,-y,-z,-w)); }

CQuatT NLMISC::CQuatT< float >::operator- const CQuatT< float > &  o  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 113 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00113 {return CQuatT(x-o.x,y-o.y,z-o.z,w-o.w);}

CQuatT& NLMISC::CQuatT< float >::operator-= const CQuatT< float > &  o  )  [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 109 of file quat.h.

References NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00109 {x-=o.x; y-=o.y; z-=o.z; w-=o.w; return *this;}

CQuatT NLMISC::CQuatT< float >::operator/ float   f  )  const [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 115 of file quat.h.

References NLMISC::CQuatT< T >::CQuatT(), w, x, y, and z.

00115 {double oof= 1.0/f; return CQuatT(x*oof,y*oof,z*oof,w*oof);}

CQuatT& NLMISC::CQuatT< float >::operator/= float   f  )  [inline, inherited]
 

return the norm of the 4D vector.

Definition at line 111 of file quat.h.

References w, x, y, and z.

00111 {double oof= 1.0/f; x=(T)(x*oof); y=(T)(y*oof); z= (T)(z*oof); w=(T)(w*oof); return *this;}

CQuat& NLMISC::CQuat::operator= const CQuatT< float > &  o  )  [inline]
 

ctor of a UNIT quaternion, from an angle axis.

Definition at line 503 of file quat.h.

References NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00503 {x=o.x; y=o.y; z=o.z; w=o.w; return *this;}

bool NLMISC::CQuatT< float >::operator== const CQuatT< float > &  a  )  const [inline, inherited]
 

Definition at line 100 of file quat.h.

References NLMISC::CQuatT< T >::w, w, NLMISC::CQuatT< T >::x, x, NLMISC::CQuatT< T >::y, y, NLMISC::CQuatT< T >::z, and z.

00100 {return (x==a.x && y==a.y && z==a.z && w==a.w);}

void NLMISC::CQuatT< float >::serial IStream f  )  [inline, inherited]
 

serial.

Definition at line 168 of file quat.h.

References NLMISC::IStream::serial(), w, x, y, and z.

00169         {
00170                 f.serial(x,y,z,w);
00171         }

void NLMISC::CQuatT< float >::set float   X,
float   Y,
float   Z,
float   W
[inline, inherited]
 

Definition at line 95 of file quat.h.

References w, x, y, and z.

Referenced by NL3D::CTargetAnimCtrl::CTargetAnimCtrl().

00095 {x= X; y= Y; z= Z; w= W;}

void NLMISC::CQuatT< float >::setAngleAxis const CAngleAxis angAxis  )  [inline, inherited]
 

Build a UNIT quaternion from an AngleAxis.

Definition at line 155 of file quat.h.

References NLMISC::CAngleAxis::Angle, NLMISC::CAngleAxis::Axis, and NLMISC::CQuatT< T >::setAngleAxis().

00155 {setAngleAxis(angAxis.Axis, angAxis.Angle);}

void NLMISC::CQuatT< float >::setAngleAxis const CVector axis,
float  angle
[inherited]
 

Build a UNIT quaternion from an AngleAxis.

Referenced by NL3D::CTargetAnimCtrl::execute().

CQuatT NLMISC::CQuatT< float >::slerp const CQuatT< float > &  q0,
const CQuatT< float > &  q1,
float  t
[static, inherited]
 

Quaternion spherical linear interpolation. when t==0, ret==q0, when t==1, ret==q1. No hemisphere correction is made.

Referenced by NL3D::CAnimatedValueBlendable< NLMISC::CQuat >::blend().

float NLMISC::CQuatT< float >::sqrnorm  )  const [inline, inherited]
 

return the square of the norm of the 4D vector.

Definition at line 119 of file quat.h.

References w, x, y, and z.

00119 {return (x*x + y*y + z*z + w*w);}

CQuatT NLMISC::CQuatT< float >::squad const CQuatT< float > &  q0,
const CQuatT< float > &  tgtQ0,
const CQuatT< float > &  tgtQ1,
const CQuatT< float > &  q1,
float  t
[static, inherited]
 

Quaternion Quadratic spherical linear interpolation. when t==0, ret==q0, when t==1, ret==q1. No hemisphere correction is made.

CQuatT NLMISC::CQuatT< float >::squadrev const CAngleAxis rot,
const CQuatT< float > &  q0,
const CQuatT< float > &  tgtQ0,
const CQuatT< float > &  tgtQ1,
const CQuatT< float > &  q1,
float  t
[static, inherited]
 

Quaternion Quadratic spherical linear interpolation, with multi revision support.


Field Documentation

const CQuat NLMISC::CQuat::Identity [static]
 

Definition at line 35 of file quat.cpp.

float NLMISC::CQuatT< float >::w [inherited]
 

Definition at line 77 of file quat.h.

Referenced by NLMISC::CQuatD::CQuatD(), NLMISC::CMatrix::getRot(), and NLMISC::CMatrix::setRot().

float NLMISC::CQuatT< float >::x [inherited]
 

Definition at line 77 of file quat.h.

Referenced by NLMISC::CQuatD::CQuatD(), NLMISC::CMatrix::getRot(), and NLMISC::CMatrix::setRot().

float NLMISC::CQuatT< float >::y [inherited]
 

Definition at line 77 of file quat.h.

Referenced by NLMISC::CQuatD::CQuatD(), NLMISC::CMatrix::getRot(), and NLMISC::CMatrix::setRot().

float NLMISC::CQuatT< float >::z [inherited]
 

Definition at line 77 of file quat.h.

Referenced by NLMISC::CQuatD::CQuatD(), NLMISC::CMatrix::getRot(), and NLMISC::CMatrix::setRot().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:29:38 2004 for NeL by doxygen 1.3.6