Classes | Functions

quat.h File Reference

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

Go to the source code of this file.

Classes

class   AngAxis
class   Quat

Functions

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

Function Documentation

GEOMEXPORT Quat operator* ( float  ,
const Quat  
)
Remarks:
Multiplies the quaternion by a scalar.
GEOMEXPORT Quat operator* ( const Quat ,
float   
)
Remarks:
Multiplies the quaternion by a scalar.
GEOMEXPORT Quat operator/ ( const Quat ,
float   
)
Remarks:
Divides the quaternion by a scalar.
GEOMEXPORT Quat Inverse ( const Quat q )
Remarks:
Returns the inverse of the quaternion (1/q).
GEOMEXPORT Quat Conjugate ( const Quat q )
Remarks:
Returns the conjugate of a quaternion.
GEOMEXPORT Quat LogN ( const Quat q )
Remarks:
Returns the natural logarithm of UNIT quaternion.
GEOMEXPORT Quat Exp ( const Quat q )
Remarks:
Exponentiate quaternion (where q.w==0).
GEOMEXPORT 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)
GEOMEXPORT Quat LnDif ( const Quat p,
const Quat q 
)
Remarks:
Computes the "log difference" of two quaternions, p and q, as ln(qinv(p)*q).
GEOMEXPORT 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] )))
GEOMEXPORT 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).
GEOMEXPORT Quat qorthog ( const Quat p,
const Point3 axis 
)
Remarks:
Rotate p by 90 degrees (quaternion space metric) about the specified axis.
GEOMEXPORT 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]
GEOMEXPORT 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.
GEOMEXPORT 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.
GEOMEXPORT Quat QFromAngAxis ( float  ang,
const Point3 axis 
)
Remarks:
Converts the [angle,axis] representation to the equivalent quaternion.
GEOMEXPORT void AngAxisFromQ ( const Quat q,
float *  ang,
Point3 axis 
)
Remarks:
Converts the quaternion to the equivalent [angle,axis] representation.
GEOMEXPORT 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.
GEOMEXPORT 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.
GEOMEXPORT 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)).

Definition at line 369 of file quat.h.

{ return(Quat(0.0,0.0,0.0,1.0)); }
GEOMEXPORT 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.
GEOMEXPORT 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:

void EulerToQuat(float *ang, Quat \&q, int order) {
    Matrix3 mat(1);</b>\n\n
    for (int i=0; i\<3; i++) {
        switch (orderings[order][i]) {
            case 0: mat.RotateX(ang[i]); break;
            case 1: mat.RotateY(ang[i]); break;
            case 2: mat.RotateZ(ang[i]); break;
        }
    }
    q = Quat(mat);
}
GEOMEXPORT std::ostream& operator<< ( std::ostream &  ,
const Quat  
)