quat.h File Reference

#include "GeomExport.h"
#include "maxheap.h"
#include "matrix3.h"
#include "assert1.h"
#include <iosfwd>

Classes

class  AngAxis
 
class  Quat
 

Functions

Quat operator* (float, const Quat &)
 
Quat operator* (const Quat &, float)
 
Quat operator/ (const Quat &, float)
 
Quat Inverse (const Quat &q)
 
Quat Conjugate (const Quat &q)
 
Quat LogN (const Quat &q)
 
Quat Exp (const Quat &q)
 
Quat Slerp (const Quat &p, const Quat &q, float t)
 
Quat LnDif (const Quat &p, const Quat &q)
 
Quat QCompA (const Quat &qprev, const Quat &q, const Quat &qnext)
 
Quat Squad (const Quat &p, const Quat &a, const Quat &b, const Quat &q, float t)
 
Quat qorthog (const Quat &p, const Point3 &axis)
 
Quat squadrev (float angle, const Point3 &axis, const Quat &p, const Quat &a, const Quat &b, const Quat &q, float t)
 
void RotateMatrix (Matrix3 &mat, const Quat &q)
 
void PreRotateMatrix (Matrix3 &mat, const Quat &q)
 
Quat QFromAngAxis (float ang, const Point3 &axis)
 
void AngAxisFromQ (const Quat &q, float *ang, Point3 &axis)
 
float QangAxis (const Quat &p, const Quat &q, Point3 &axis)
 
void DecomposeMatrix (const Matrix3 &mat, Point3 &p, Quat &q, Point3 &s)
 
Quat TransformQuat (const Matrix3 &m, const Quat &q)
 
Quat IdentQuat ()
 
void QuatToEuler (Quat &q, float *ang)
 
void EulerToQuat (float *ang, Quat &q)
 
M_STD_OSTREAMoperator<< (M_STD_OSTREAM &, const Quat &)
 

Function Documentation

Quat operator* ( float  ,
const Quat  
)
Remarks
Multiplies the quaternion by a scalar.
Quat operator* ( const Quat ,
float   
)
Remarks
Multiplies the quaternion by a scalar.
Quat operator/ ( const Quat ,
float   
)
Remarks
Divides the quaternion by a scalar.
Quat Inverse ( const Quat q)
Remarks
Returns the inverse of the quaternion (1/q).
Quat Conjugate ( const Quat q)
Remarks
Returns the conjugate of a quaternion.
Quat LogN ( const Quat q)
Remarks
Returns the natural logarithm of UNIT quaternion.
Quat Exp ( const Quat q)
Remarks
Exponentiate quaternion (where q.w==0).
Quat Slerp ( const Quat p,
const Quat q,
float  t 
)
Remarks
Spherical linear interpolation of UNIT quaternions.

As t goes from 0 to 1, qt goes from p to q.

slerp(p,q,t) = (p*sin((1-t)*omega) + q*sin(t*omega)) / sin(omega)
Quat LnDif ( const Quat p,
const Quat q 
)
Remarks
Computes the "log difference" of two quaternions, p and q, as ln(qinv(p)*q).
Quat QCompA ( const Quat qprev,
const Quat q,
const Quat qnext 
)
Remarks
Compute a, the term used in Boehm-type interpolation.

a[n] = q[n]* qexp(-(1/4)*( ln(qinv(q[n])*q[n+1]) +ln( qinv(q[n])*q[n-1] )))
Quat Squad ( const Quat p,
const Quat a,
const Quat b,
const Quat q,
float  t 
)
Remarks
Squad(p,a,b,q; t) = Slerp(Slerp(p,q;t), Slerp(a,b;t); 2(1-t)t).
Quat qorthog ( const Quat p,
const Point3 axis 
)
Remarks
Rotate p by 90 degrees (quaternion space metric) about the specified axis.
Quat squadrev ( float  angle,
const Point3 axis,
const Quat p,
const Quat a,
const Quat b,
const Quat q,
float  t 
)
Remarks
Quaternion interpolation for angles > 2PI.
Parameters:
float angle

Angle of rotation

const Point3& axis

The axis of rotation

const Quat& p

Start quaternion

const Quat& a

Start tangent quaternion

const Quat& b

End tangent quaternion

const Quat& q

End quaternion

float t

Parameter, in range [0.0,1.0]
void RotateMatrix ( Matrix3 mat,
const Quat q 
)
Remarks
Converts the quaternion to a matrix and multiples it by the specified matrix. The result is returned in mat.
void PreRotateMatrix ( Matrix3 mat,
const Quat q 
)
Remarks
Converts the quaternion to a matrix and multiples it on the left by the specified matrix. . The result is returned in mat.
Quat QFromAngAxis ( float  ang,
const Point3 axis 
)
Remarks
Converts the [angle,axis] representation to the equivalent quaternion.
void AngAxisFromQ ( const Quat q,
float *  ang,
Point3 axis 
)
Remarks
Converts the quaternion to the equivalent [angle,axis] representation.
float QangAxis ( const Quat p,
const Quat q,
Point3 axis 
)
Remarks
Compute the [angle,axis] corresponding to the rotation from p to q. Returns angle, sets axis.
void DecomposeMatrix ( const Matrix3 mat,
Point3 p,
Quat q,
Point3 s 
)
Remarks
Decomposes a matrix into a rotation, scale, and translation (to be applied in that order). This only will work correctly for scaling which was applied in the rotated axis system. For more general decomposition see the function decomp_affine(). See Structure AffineParts.
Quat TransformQuat ( const Matrix3 m,
const Quat q 
)
Remarks
Returns the transformation of the specified quaternion by the specified matrix.
Quat IdentQuat ( )
inline
Remarks
Returns the identity quaternion (Quat(0.0,0.0,0.0,1.0)).
374 { return(Quat(0.0,0.0,0.0,1.0)); }
Definition: quat.h:146
void QuatToEuler ( Quat q,
float *  ang 
)
Remarks
Converts the quaternion to Euler angles. When converting a quaternion to Euler angles using this method, the correct order of application of the resulting three rotations is X, then Y, then Z. The angles are returned as ang[0]=x, ang[1]=y, ang[2]=z.
void EulerToQuat ( float *  ang,
Quat q 
)
Remarks
Converts Euler angles to a quaternion. The angles are specified as ang[0]=x, ang[1]=y, ang[2]=z. This method is implemented as:

1 void EulerToQuat(float *ang, Quat \&q, int order) {
2  Matrix3 mat(1);</b>\n\n
3  for (int i=0; i<3; i++) {
4  switch (orderings[order][i]) {
5  case 0: mat.RotateX(ang[i]); break;
6  case 1: mat.RotateY(ang[i]); break;
7  case 2: mat.RotateZ(ang[i]); break;
8  }
9  }
10  q = Quat(mat);
11 }
M_STD_OSTREAM& operator<< ( M_STD_OSTREAM ,
const Quat  
)