From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03297.html | 2331 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2331 insertions(+) create mode 100644 docs/doxygen/nel/a03297.html (limited to 'docs/doxygen/nel/a03297.html') diff --git a/docs/doxygen/nel/a03297.html b/docs/doxygen/nel/a03297.html new file mode 100644 index 00000000..d28e727e --- /dev/null +++ b/docs/doxygen/nel/a03297.html @@ -0,0 +1,2331 @@ + + +NeL: TemplateNLMISC::CQuatT< T > class Reference + + + +
+

NLMISC::CQuatT< T > Class Template Reference

#include <quat.h> +

+


Detailed Description

+

template<class T>
+ class NLMISC::CQuatT< T >

+ +A Template quaternion. Use CQuat and CQuatD.
Author:
Antoine Viau.

+Nevrax France

+
Date:
2000
+ +

+ +

+Definition at line 74 of file quat.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

Basic Quaternions operations.
CQuatT conjugate () const
 return the conjugate of this quaternion.

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

CQuatT inverted () const
 return the quaternion inverted.

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

CQuatToperator *= (const CQuatT &)
 return the conjugate of this quaternion.

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

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

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

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

Comparison
bool equal (const CQuatT &a, float epsilon=1E-6f) const
void identity ()
bool isIdentity () const
bool operator== (const CQuatT &a) const
Misc.
CQuatT exp ()
 compute quaternion exponent.

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.

void serial (IStream &f)
 serial.

To/From other orientation.
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 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.

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

void normalize ()
 Normalize the quaternion.

CQuatT normed () const
 Return the quaternion normalized.

CQuatT operator * (T f) const
 return the norm of the 4D vector.

CQuatToperator *= (T f)
 return the norm of the 4D vector.

CQuatT operator+ () const
 return the norm of the 4D vector.

CQuatT operator+ (const CQuatT &o) const
 return the norm of the 4D vector.

CQuatToperator+= (const CQuatT &o)
 return the norm of the 4D vector.

CQuatT operator- () const
 return the norm of the 4D vector.

CQuatT operator- (const CQuatT &o) const
 return the norm of the 4D vector.

CQuatToperator-= (const CQuatT &o)
 return the norm of the 4D vector.

CQuatT operator/ (T f) const
 return the norm of the 4D vector.

CQuatToperator/= (T f)
 return the norm of the 4D vector.

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

Sets.
void set (T X, T Y, T Z, T W)

Static Public Member Functions

Quaternions static functions.
dotProduct (const CQuatT< T > &q0, const CQuatT< T > &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< T > &q0, const CQuatT< T > &q1, float t)
CQuatT squad (const CQuatT< T > &q0, const CQuatT< T > &tgtQ0, const CQuatT< T > &tgtQ1, const CQuatT< T > &q1, float t)
CQuatT squadrev (const CAngleAxis &rot, const CQuatT< T > &q0, const CQuatT< T > &tgtQ0, const CQuatT< T > &tgtQ1, const CQuatT< T > &q1, float t)

Data Fields

w
x
y
z
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
NLMISC::CQuatT< T >::CQuatT  )  [inline]
+
+ + + + + +
+   + + +

+ctor of a UNIT quaternion, from an angle axis. +

+ +

+Definition at line 84 of file quat.h. +

+Referenced by NLMISC::CQuatT< float >::conjugate(), NLMISC::CQuatT< float >::operator *(), NLMISC::CQuatT< float >::operator+(), NLMISC::CQuatT< float >::operator-(), and NLMISC::CQuatT< float >::operator/(). +

+

00084 : x((T)0.0),y((T)0.0),z((T)0.0),w((T)1.0) {}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
NLMISC::CQuatT< T >::CQuatT X,
Y,
Z,
W
[inline]
+
+ + + + + +
+   + + +

+ctor of a UNIT quaternion, from an angle axis. +

+ +

+Definition at line 85 of file quat.h. +

+

00085 : x(X), y(Y), z(Z), w(W) {}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
NLMISC::CQuatT< T >::CQuatT const CVector axis,
float  angle
[inline]
+
+ + + + + +
+   + + +

+ctor of a UNIT quaternion, from an angle axis. +

+ +

+Definition at line 87 of file quat.h. +

+

00087 {setAngleAxis(axis, angle);}
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
NLMISC::CQuatT< T >::CQuatT const CAngleAxis aa  )  [inline]
+
+ + + + + +
+   + + +

+ctor of a UNIT quaternion, from an angle axis. +

+ +

+Definition at line 89 of file quat.h. +

+

00089 {setAngleAxis(aa);}
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::conjugate  )  const [inline]
+
+ + + + + +
+   + + +

+return the conjugate of this quaternion. +

+ +

+Definition at line 139 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::invert(). +

+

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

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
T NLMISC::CQuatT< T >::dotProduct const CQuatT< T > &  q0,
const CQuatT< T > &  q1
[static]
+
+ + + + + +
+   + + +

+Return the dotProduct of 2 quaternions. +

+ +

+Definition at line 309 of file quat.h. +

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

+Referenced by NLMISC::CQuatT< T >::makeClosest(). +

+

00310 {
+00311         return q0.x*q1.x + q0.y*q1.y + q0.z*q1.z + q0.w*q1.w;
+00312 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
bool NLMISC::CQuatT< T >::equal const CQuatT< T > &  a,
float  epsilon = 1E-6f
const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 227 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. +

+

00228 {
+00229         if (fabs(x-a.x)<epsilon &&
+00230                 fabs(y-a.y)<epsilon &&
+00231                 fabs(z-a.z)<epsilon &&
+00232                 fabs(w-a.w)<epsilon )
+00233         {
+00234                 return true;
+00235         }
+00236         return false;
+00237 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::exp  ) 
+
+ + + + + +
+   + + +

+compute quaternion exponent. +

+ +

+Definition at line 445 of file quat.h. +

+References len, NLMISC::QuatEpsilon, x, y, and z. +

+

00446 {
+00447         double  len;
+00448         len = sqrt (x*x + y*y + z*z);
+00449 
+00450         if (len < QuatEpsilon)
+00451                 return CQuatT<T>(0.f, 0.f, 0.f, 1.f);
+00452         else
+00453         {
+00454                 double len1 = sin(len) / len; 
+00455                 return CQuatT<T>( (T)(x*len1), (T)(y*len1), (T)(z*len1), (T)cos(len));
+00456         }
+00457 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
float NLMISC::CQuatT< T >::getAngle  )  const [inline]
+
+ + + + + +
+   + + +

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

+ +

+Definition at line 148 of file quat.h. +

+Referenced by NLMISC::CQuatT< float >::getAngleAxis(). +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CAngleAxis NLMISC::CQuatT< T >::getAngleAxis  )  const [inline]
+
+ + + + + +
+   + + +

+Return the equivalent Unit AngleAxis of this quaternion. +

+ +

+Definition at line 150 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CVector NLMISC::CQuatT< T >::getAxis void   )  const [inline]
+
+ + + + + +
+   + + +

+Return the equivalent Unit axis of this quaternion. +

+ +

+Definition at line 146 of file quat.h. +

+Referenced by NLMISC::CQuatT< float >::getAngleAxis(). +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::identity  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 102 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::normalize(). +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::invert  )  [inline]
+
+ + + + + +
+   + + +

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

+ +

+Definition at line 265 of file quat.h. +

+References NLMISC::CQuatT< T >::conjugate(), and NLMISC::CQuatT< T >::sqrnorm(). +

+Referenced by NLMISC::CQuatT< float >::inverted(). +

+

00266 {
+00267         // Must invert the norm.
+00268         T       f= sqrnorm();
+00269         if(f!=0)
+00270         {
+00271                 *this/=f;
+00272         }
+00273 
+00274         *this= conjugate();
+00275 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::inverted  )  const [inline]
+
+ + + + + +
+   + + +

+return the quaternion inverted. +

+ +

+Definition at line 137 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::lnDif(). +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
bool NLMISC::CQuatT< T >::isIdentity  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 103 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::lnDif const CQuatT< T > &  q0,
const CQuatT< T > &  q1
[static]
+
+ + + + + +
+   + + +

+compute lnDiff of q0.inverted()*q1. +

+ +

+Definition at line 462 of file quat.h. +

+References NLMISC::CQuatT< T >::inverted(), NLMISC::CQuatT< T >::log(), and NLMISC::CQuatT< T >::normalize(). +

+

00463 {
+00464         CQuatT<T>       dif = q0.inverted()*q1;
+00465         dif.normalize();
+00466 
+00467         return dif.log();
+00468 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::log  ) 
+
+ + + + + +
+   + + +

+compute logn quaternion. +

+ +

+Definition at line 427 of file quat.h. +

+References len, NLMISC::QuatEpsilon, w, x, y, and z. +

+Referenced by NLMISC::CQuatT< T >::lnDif(). +

+

00428 {
+00429         double  len;
+00430         len = sqrt (x*x + y*y + z*z);
+00431 
+00432         if (len < QuatEpsilon)
+00433                 return CQuatT<T>(0.f, 0.f, 0.f, 0.f);
+00434         else
+00435         {
+00436                 double div = (float) acos (w) / len;
+00437                 return CQuatT<T>( (T)(x*div), (T)(y*div), (T)(z*div), 0.f);
+00438         }
+00439 
+00440 }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::makeClosest const CQuatT< T > &  o  ) 
+
+ + + + + +
+   + + +

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

+ +

+Definition at line 473 of file quat.h. +

+References NLMISC::CQuatT< T >::dotProduct(). +

+

00474 {
+00475         if( dotProduct(*this, o) < 0 )
+00476                 *this= -(*this);
+00477 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
T NLMISC::CQuatT< T >::norm  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 121 of file quat.h. +

+Referenced by NLMISC::CQuatT< float >::getAngle(), and NLMISC::CQuatT< T >::normalize(). +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::normalize  )  [inline]
+
+ + + + + +
+   + + +

+Normalize the quaternion. +

+ +

+Definition at line 280 of file quat.h. +

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

+Referenced by NLMISC::CQuatT< T >::lnDif(), and NLMISC::CQuatT< float >::normed(). +

+

00281 {
+00282         T       f= norm();
+00283         if(f==0)
+00284                 identity();
+00285         else
+00286         {
+00287                 *this/=f;
+00288         }
+00289 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::normed  )  const [inline]
+
+ + + + + +
+   + + +

+Return the quaternion normalized. +

+ +

+Definition at line 125 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::operator * const CQuatT< T > &   )  const [inline]
+
+ + + + + +
+   + + +

+Quaternion multiplication/composition. +

+ +

+Definition at line 242 of file quat.h. +

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

+

00243 {
+00244         // wres= ww´ - v·v´
+00245         // vres= wv´ + w´v + v^v´ ] 
+00246         return  CQuatT<T>(
+00247                                         (w*o.x) +(x*o.w) + (y*o.z)-(z*o.y),
+00248                                         (w*o.y) +(y*o.w) + (z*o.x)-(x*o.z),
+00249                                         (w*o.z) +(z*o.w) + (x*o.y)-(y*o.x),
+00250                                         (w*o.w)-(x*o.x)-(y*o.y)-(z*o.z) );
+00251 
+00252 }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator * f  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 114 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT< T > & NLMISC::CQuatT< T >::operator *= const CQuatT< T > &   )  [inline]
+
+ + + + + +
+   + + +

+return the conjugate of this quaternion. +

+ +

+Definition at line 256 of file quat.h. +

+

00257 {
+00258         *this= *this * o;
+00259         return *this;
+00260 }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT& NLMISC::CQuatT< T >::operator *= f  )  [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 110 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator+  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 117 of file quat.h. +

+

00117 {return *this; }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator+ const CQuatT< T > &  o  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 112 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT& NLMISC::CQuatT< T >::operator+= const CQuatT< T > &  o  )  [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 108 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator-  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 116 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator- const CQuatT< T > &  o  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 113 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT& NLMISC::CQuatT< T >::operator-= const CQuatT< T > &  o  )  [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 109 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT NLMISC::CQuatT< T >::operator/ f  )  const [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 115 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
CQuatT& NLMISC::CQuatT< T >::operator/= f  )  [inline]
+
+ + + + + +
+   + + +

+return the norm of the 4D vector. +

+ +

+Definition at line 111 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
bool NLMISC::CQuatT< T >::operator== const CQuatT< T > &  a  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 100 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::serial IStream f  )  [inline]
+
+ + + + + +
+   + + +

+serial. +

+ +

+Definition at line 168 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::set X,
Y,
Z,
W
[inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 95 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::squadrev(). +

+

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

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::setAngleAxis const CAngleAxis angAxis  )  [inline]
+
+ + + + + +
+   + + +

+Build a UNIT quaternion from an AngleAxis. +

+ +

+Definition at line 155 of file quat.h. +

+

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

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
void NLMISC::CQuatT< T >::setAngleAxis const CVector axis,
float  angle
[inline]
+
+ + + + + +
+   + + +

+Build a UNIT quaternion from an AngleAxis. +

+ +

+Definition at line 294 of file quat.h. +

+References v, w, x, y, and z. +

+Referenced by NLMISC::CQuatT< float >::CQuatT(), and NLMISC::CQuatT< float >::setAngleAxis(). +

+

00295 {
+00296         CVector         v= axis;
+00297         v.normalize();
+00298         double  ca= cos(angle/2);
+00299         double  sa= sin(angle/2);
+00300         x= (T)(v.x*sa);
+00301         y= (T)(v.y*sa);
+00302         z= (T)(v.z*sa);
+00303         w= (T)(ca);
+00304 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::slerp const CQuatT< T > &  q0,
const CQuatT< T > &  q1,
float  t
[static]
+
+ + + + + +
+   + + +

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

+Definition at line 317 of file quat.h. +

+References t. +

+Referenced by NLMISC::CQuatT< T >::squad(). +

+

00318 {
+00319         // omega is the 4D angle between q0 and q1.
+00320         double  omega, cosom,sinom;
+00321         T       factq0= 1;
+00322         T       s0,s1;
+00323 
+00324         cosom = CQuatT<T>::dotProduct(q0, q1);
+00325 
+00326         // Make q0 and q1 on the same hemisphere.
+00327         /*if(cosom<0)
+00328         {
+00329                 cosom= -cosom;
+00330                 factq0= -1;
+00331         }*/
+00332         // ????
+00333 
+00334         if ( cosom < 1.0 - NLMISC::QuatEpsilon)
+00335         { 
+00336                 omega = acos(cosom);
+00337                 sinom = sin(omega);
+00338                 s0 = (T) (sin((1.0f - t)*omega) / sinom);
+00339                 s1 = (T) (sin(t*omega) / sinom);
+00340         }
+00341         else
+00342         {       // q0 and q1 are nearly the same => sinom nearly 0. We can't slerp.
+00343                 // just linear interpolate.
+00344                 s0 = (T)(1.0 - t);
+00345                 s1 = t;
+00346         }
+00347 
+00348         return  q0*(factq0*s0) + q1*s1;
+00349 
+00350 }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
T NLMISC::CQuatT< T >::sqrnorm  )  const [inline]
+
+ + + + + +
+   + + +

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

+ +

+Definition at line 119 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::invert(), and NLMISC::CQuatT< float >::norm(). +

+

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

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T>
CQuatT< T > NLMISC::CQuatT< T >::squad const CQuatT< T > &  q0,
const CQuatT< T > &  tgtQ0,
const CQuatT< T > &  tgtQ1,
const CQuatT< T > &  q1,
float  t
[static]
+
+ + + + + +
+   + + +

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

+Definition at line 355 of file quat.h. +

+References NLMISC::CQuatT< T >::slerp(), and t. +

+

00356 {
+00357         return CQuatT<T>::slerp(
+00358                 CQuatT<T>::slerp(q0, q1, t),
+00359                 CQuatT<T>::slerp(tgtQ0, tgtQ1, t),
+00360                 2.f*(1.f-t)*t);
+00361 }
+
+

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

+Quaternion Quadratic spherical linear interpolation, with multi revision support. +

+Definition at line 366 of file quat.h. +

+References NLMISC::CAngleAxis::Angle, NLMISC::CAngleAxis::Axis, NLMISC::Pi, NLMISC::QuatEpsilon, s, NLMISC::CQuatT< T >::set(), t, v, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+

00367 {
+00368         float s,v;
+00369         float omega = rot.Angle* 0.5f;
+00370         float nrevs = 0.0f;
+00371         CQuatT<T>       ret,qaxis,pp,qq;
+00372 
+00373         // just one rev?
+00374         //==============
+00375         if (omega<Pi-QuatEpsilon)
+00376         {
+00377                 ret = CQuatT<T>::squad(q0,tgtQ0,tgtQ1,q1,t);
+00378                 return ret; 
+00379         }
+00380 
+00381 
+00382         // multirev.
+00383         //==============
+00384 
+00385         // rotation of 180deg around rot.Axis.  (=> sin(a/2)==sin(Pi/2)==1, and c(a/2)=0).
+00386         qaxis.set(rot.Axis.x, rot.Axis.y, rot.Axis.z, 0);
+00387 
+00388         // the number of revisions (float!)
+00389         nrevs= (float)(omega/Pi);
+00390         // Angle>2Pi. squad from 0 to Pi, slerp from Pi to Angle-Pi, squad from Angle-Pi to Angle.
+00391         s = t*2*nrevs;
+00392         
+00393 
+00394         // So for s, squad from 0 to 1, slerp from 1 to 2*nrevs-1, squad from 2*nrevs-1 to 2*nrevs.
+00395         if (s < 1.0f)
+00396         {
+00397                 // first part.
+00398                 pp = q0*qaxis;
+00399                 ret = CQuatT<T>::squad(q0,tgtQ0,pp,pp,s);
+00400         }
+00401         else
+00402         {
+00403                 v = s - (2.0f*nrevs - 1.0f);
+00404                 if( v <= 0.0f)
+00405                 {
+00406                         // middle part
+00407                         while (s >= 2.0f) s -= 2.0f;
+00408                         pp = q0*qaxis;
+00409                         // s vary from 1 to 2. This is still correct for slerp().
+00410                         ret = CQuatT<T>::slerp(q0,pp,s);
+00411                 }
+00412                 else
+00413                 {
+00414                         // Last part.
+00415                         qq = - q1*qaxis;
+00416                         ret= CQuatT<T>::squad(qq,qq,tgtQ1,q1,v);
+00417                 }
+00418         }
+00419 
+00420         return ret;
+00421 }
+
+


Field Documentation

+

+ + + + +
+ + + + + +
+template<class T>
T NLMISC::CQuatT< T >::w +
+
+ + + + + +
+   + + +

+ +

+Definition at line 77 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::dotProduct(), NLMISC::CQuatT< T >::equal(), NLMISC::CQuatT< T >::operator *(), NLMISC::CQuatT< float >::operator+(), NLMISC::CQuatT< float >::operator+=(), NLMISC::CQuatT< float >::operator-(), NLMISC::CQuatT< float >::operator-=(), NLMISC::CQuatD::operator=(), NLMISC::CQuat::operator=(), and NLMISC::CQuatT< float >::operator==().

+

+ + + + +
+ + + + + +
+template<class T>
T NLMISC::CQuatT< T >::x +
+
+ + + + + +
+   + + +

+ +

+Definition at line 77 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::dotProduct(), NLMISC::CQuatT< T >::equal(), NLMISC::CQuatT< T >::operator *(), NLMISC::CQuatT< float >::operator+(), NLMISC::CQuatT< float >::operator+=(), NLMISC::CQuatT< float >::operator-(), NLMISC::CQuatT< float >::operator-=(), NLMISC::CQuatD::operator=(), NLMISC::CQuat::operator=(), and NLMISC::CQuatT< float >::operator==().

+

+ + + + +
+ + + + + +
+template<class T>
T NLMISC::CQuatT< T >::y +
+
+ + + + + +
+   + + +

+ +

+Definition at line 77 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::dotProduct(), NLMISC::CQuatT< T >::equal(), NLMISC::CQuatT< T >::operator *(), NLMISC::CQuatT< float >::operator+(), NLMISC::CQuatT< float >::operator+=(), NLMISC::CQuatT< float >::operator-(), NLMISC::CQuatT< float >::operator-=(), NLMISC::CQuatD::operator=(), NLMISC::CQuat::operator=(), and NLMISC::CQuatT< float >::operator==().

+

+ + + + +
+ + + + + +
+template<class T>
T NLMISC::CQuatT< T >::z +
+
+ + + + + +
+   + + +

+ +

+Definition at line 77 of file quat.h. +

+Referenced by NLMISC::CQuatT< T >::dotProduct(), NLMISC::CQuatT< T >::equal(), NLMISC::CQuatT< T >::operator *(), NLMISC::CQuatT< float >::operator+(), NLMISC::CQuatT< float >::operator+=(), NLMISC::CQuatT< float >::operator-(), NLMISC::CQuatT< float >::operator-=(), NLMISC::CQuatD::operator=(), NLMISC::CQuat::operator=(), and NLMISC::CQuatT< float >::operator==().

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:30:51 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1