Physsim::Quat Class Reference

Quaternion class used for orientation. More...

#include <Quat.h>

Inheritance diagram for Physsim::Quat:

Physsim::Base List of all members.

Public Member Functions

 Quat ()
 Default constructor.
 Quat (Real x, Real y, Real z, Real w)
 Constructs a quaternion from four Real values.
 Quat (boost::shared_array< const Real > q)
 Constructs a quaternion from a Real array of length 4.
 Quat (const Quat &q)
 Copy constructor.
 Quat (const VectorN &v)
 Constructs a quaternion from a vector.
 Quat (const Matrix3 *m)
 Constructs a quaternion from a rotation matrix.
 Quat (const Matrix4 *m)
 Constructs a quaternion from a transformation matrix.
 Quat (const AAngle *a)
 Constructs a quaternion from an axis-angle object.
void conjugate ()
 Negates the value of each of the x, y, and z coordinates in place.
bool epsilon_equals (const Quat &q, Real epsilon)
 Determines whether this quaternion is equal to another within the given tolerance.
void slerp (const Quat &q, Real alpha)
 Performs spherical linear interpolation between this and q.
void inverse ()
 Computes the inverse orientation represented by this quaternion in place.
void normalize ()
 Normalizes this quaternion in place.
void set (const VectorN &v)
void set (const AAngle *a)
 Sets this to that represented by an axis-angle representation.
void set (const Matrix3 *m)
 Sets this quaternion to that represented by a rotation matrix.
void set (const Matrix4 *m)
 Sets this quaternion to that represented by the rotation component of a transformation matrix.
Quat operator- (const Quat &q) const
 Subtracts a quaternion from this.
void operator-= (const Quat &q)
 Subtracts one quaternion from another.
Quat operator+ (const Quat &q) const
 Adds this quaternion to another and returns the result in a new quaternion.
void operator+= (const Quat &q)
 Adds this quaon to another and stores the result in this.
void operator= (const Quat &q)
 Copy operator.
Quat operator * (const Quat &q) const
 Multiplies this by q and returns the result.
Quat operator * (Real scalar) const
 Multiplies a quaternion by a scalar.
void operator *= (const Quat &q)
 Multiplies this by q and stores the result in this.
void operator *= (Real scalar)
 Multiplies a quaternion by a scalar and stores the result in this.
Real magnitude () const
 Calculates the magnitude of a quaternion.

Static Public Member Functions

static Quat zero ()
 Constructs a zero quaternion.
static Quat conjugate (const Quat &q)
 Negates the value of each of the x, y, and z coordinates of the given quaternion.
static bool epsilon_equals (const Quat &q1, const Quat &q2, Real epsilon)
 Determines whether to quaternions are equal to within the given tolerance.
static Quat slerp (const Quat &q1, const Quat &q2, Real alpha)
 Performs spherical linear interpolation between this and q.
static Quat inverse (const Quat &q)
 Computes the inverse orientation of a quaternion.
static Quat normalize (const Quat &q)
 Computes the normalized quaternion of q.
static Quat deriv (const Quat &q, const Vector3 &w)
 Computes the derivative of a quaternion given current orientation and angular velocity.
static Vector3 to_omega (const Quat &q, const Quat &qd)
 Computes the angular velocity of a body given the current quaternion orientation and the quaternion velocity.

Public Attributes

Real _x
 First quaternion component.
Real _y
 Second quaternion component.
Real _z
 Third quaterion component.
Real _w
 Fourth quaternion component.

Detailed Description

Quaternion class used for orientation.

This class is used to represent orientation via unit quaternions. Note, however, that the user is responsible for normalizing the quaternions; normalization is not automatic.


Constructor & Destructor Documentation

Quat::Quat (  ) 

Default constructor.

Quaternion constructed as [0,0,0] 1

Quat::Quat ( Real  x,
Real  y,
Real  z,
Real  w 
)

Constructs a quaternion from four Real values.

Parameters:
x the first component of the vector
y the second component of the vector
z the third component of the vector
w the scalar component of the quaternion

Quat::Quat ( const VectorN v  ) 

Constructs a quaternion from a vector.

Parameters:
v a four-dimensional vector (components 0..2 are the vector component, component 3 is the angular component)


Member Function Documentation

Quat Quat::conjugate ( const Quat q  )  [static]

Negates the value of each of the x, y, and z coordinates of the given quaternion.

Parameters:
q the quaternion from which the conjugate is to be computed

void Quat::slerp ( const Quat q,
Real  alpha 
)

Performs spherical linear interpolation between this and q.

Sets the orientation represented by this quaternion to a linear interpolated orientation between this and q. If alpha is 0, then *this is unaltered. If alpha is 1, then *this is set to q.

Parameters:
q the "final" orientation
alpha interpolation value (0 <= alpha <= 1)

Quat Quat::slerp ( const Quat q1,
const Quat q2,
Real  alpha 
) [static]

Performs spherical linear interpolation between this and q.

Calculates the orientation of determined by linear interpolation between q1 and q2. If alpha is 0, then q1 is returned. If alpha is 1, then q2 is returned.

Parameters:
q1 the "initial" orientation
q2 the "final" orientation
alpha interpolation value (0 <= alpha <= 1)
Returns:
the orientation linearly interpolated between q1 and q2

void Quat::set ( const VectorN v  ) 

Parameters:
v a four-dimensional vector (components 0..2 are the vector component, component 3 is the angular component)

Quat Quat::deriv ( const Quat q,
const Vector3 w 
) [static]

Computes the derivative of a quaternion given current orientation and angular velocity.

Note that the derivative is not generally a unit quaternion.

Parameters:
q the current orientation
w the angular velocity


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:23 2007 for Physsim by  doxygen 1.5.1