Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Quat Class Reference
[Data classes]

Quaternion class using double-precision. More...

#include <Quat.h>

Inheritance diagram for Quat:

BaseType List of all members.

Public Methods

virtual void serialize (Archive &)
 Serialize to or from a data archive.

virtual void parseXML (const char *cdata)
 Internal method used by the XML parser.

virtual std::string asString () const
 Standard representation string.

virtual std::string typeString () const
 Return a string representation of the type.

 Quat ()
 Construct a new quaternion.

 Quat (double x_, double y_, double z_, double w_)
 Construct a new quaternion.

 Quat (double angle, const Vector3 &axis)
 Construct a new quaternion representing a rotation.

 Quat (const Matrix3 &m)
 Construct a new quaternion representing a rotation.

 Quat (double angle1, const Vector3 &axis1, double angle2, const Vector3 &axis2, double angle3, const Vector3 &axis3)
 Construct a new quaternion representing a product of three rotations.

const Vector3 asVector3 () const
 Return the 3-vector component of the quaternion (x,y,z).

void set (double x_, double y_, double z_, double w_)
 Set the components.

double & operator[] (int i)
 Access a component by index (0,1,2,3 = x,y,z,w).

double operator[] (int i) const
 Get a component value by index (0,1,2,3 = x,y,z,w).

double & x ()
 X component accessor.

double & y ()
 Y component accessor.

double & z ()
 Z component accessor.

double & w ()
 W component accessor.

double x () const
 X component const accessor.

double y () const
 Y component const accessor.

double z () const
 Z component const accessor.

double w () const
 W component const accessor.

bool operator== (Quat const &rhs) const
 Test equality.

bool operator!= (Quat const &rhs) const
 Test inequality.

bool zeroRotation () const
 Test if the quaternion is zero.

const Quat operator * (double rhs) const
 Multiply by scalar.

Quat & operator *= (double rhs)
 Unary multiply by scalar.

const Quat operator * (const Quat &rhs) const
 Binary multiply --- adjusted relative to osg for active transformations!

Quat & operator *= (const Quat &rhs)
 Unary multiply --- adjusted relative to osg for active transformations!

const Quat operator/ (double rhs) const
 Divide by scalar.

Quat & operator/= (double rhs)
 Unary divide by scalar.

const Quat operator/ (const Quat &denom) const
 Binary divide.

Quat & operator/= (const Quat &denom)
 Unary divide.

const Quat operator+ (const Quat &rhs) const
 Binary addition.

Quat & operator+= (const Quat &rhs)
 Unary addition.

const Quat operator- (const Quat &rhs) const
 Binary subtraction.

Quat & operator-= (const Quat &rhs)
 Unary subtraction.

const Quat operator- () const
 Negation operator- returns the negative of the quaternion.

double length () const
 Length of the quaternion = sqrt(vec . vec).

double length2 () const
 Squared length of the quaternion = vec . vec.

Quat conj () const
 Get conjugate.

Quat operator~ () const
 Get conjugate.

const Quat inverse () const
 Multiplicative inverse method: q^(-1) = q^*/(q.q^*).

void makeRotate (double angle, double x, double y, double z)
 Set this Quat to represent a rotation about an axis.

void makeRotate (double angle, const Vector3 &vec)
 Set this Quat to represent a rotation about an axis.

void makeRotate (double angle1, const Vector3 &axis1, double angle2, const Vector3 &axis2, double angle3, const Vector3 &axis3)
 Set this Quat to represent a product of three rotations.

void makeRotate (const Vector3 &vec1, const Vector3 &vec2)
 Set this Quat to represent a rotation that transforms vec1 to vec2.

void makeRotate (double roll, double pitch, double yaw)
 Set this Quat to represent a rotation defined by Euler angles.

void getEulerAngles (double &roll, double &pitch, double &yaw) const
void getRotate (double &angle, double &x, double &y, double &z) const
 Return the angle and vector components represented by the quaternion.

void getRotate (double &angle, Vector3 &vec) const
 Return the angle and vector represented by the quaternion.

void slerp (double t, const Quat &from, const Quat &to)
 Spherical Linear Interpolation.

void set (const Matrix3 &m)
 Set quaternion to be equivalent to specified matrix.

void get (Matrix3 &m) const
 Get the equivalent matrix for this quaternion.

Matrix3 getMatrix3 () const
 Get the equivalent matrix for this quaternion.

Vector3 rotate (const Vector3 &v) const
 Rotate a vector by this quaternion.

Vector3 invrotate (const Vector3 &v) const
 Rotate a vector by the inverse of this quaternion.

Quat rotate (const Quat &q) const
 Rotate another quaternion by this quaternion.

Quat invrotate (const Quat &q) const
 Rotate another quaternion by the inverse of this quaternion.

virtual void convertXML ()
 Convert XML data to internal format prior to serialization.


Static Public Attributes

const Quat IDENTITY
 The identity Quat = (0,0,0,1).

const Quat ZERO
 The zero Quat = (0,0,0,0).


Friends

std::ostream & operator<< (std::ostream &output, const Quat &vec)
 Format to an output stream.

Quat operator * (double lhs, const Quat &rhs)
 Multiply a Quat by a scalar value on the left.

Quat operator * (Quat const &lhs, Vector3 const &rhs)
 Multiply a Quat by a vector on the right.

Quat operator * (Vector3 const &lhs, Quat const &rhs)
 Multiply a Quat by a vector on the left.


Detailed Description

Quaternion class using double-precision.

Quaternions are four dimensional objects that form a compact representation for rotations. Many thorough treatments of quaternions and their use in simulations can be readily found on the web.


Constructor & Destructor Documentation

Quat::Quat   [inline]
 

Construct a new quaternion.

Initialize to (0,0,0,0)

Quat::Quat double    x_,
double    y_,
double    z_,
double    w_
[inline]
 

Construct a new quaternion.

Specifiy the four real-valued components.

Quat::Quat double    angle,
const Vector3   axis
[inline]
 

Construct a new quaternion representing a rotation.

Parameters:
angle  the rotation angle (right-handed) in radians.
axis  the rotation axis.

Quat::Quat const Matrix3   m [inline]
 

Construct a new quaternion representing a rotation.

Parameters:
m  a matrix specifying the rotation.

Quat::Quat double    angle1,
const Vector3   axis1,
double    angle2,
const Vector3   axis2,
double    angle3,
const Vector3   axis3
[inline]
 

Construct a new quaternion representing a product of three rotations.

Parameters:
angle1  the first rotation angle (right-handed) in radians.
axis1  the first rotation axis.
angle2  the second rotation angle (right-handed) in radians.
axis2  the second rotation axis.
angle3  the third rotation angle (right-handed) in radians.
axis3  the third rotation axis.


Member Function Documentation

std::string Quat::asString   [virtual]
 

Standard representation string.

Implements BaseType.

const Vector3 Quat::asVector3   const [inline]
 

Return the 3-vector component of the quaternion (x,y,z).

Quat Quat::conj   const [inline]
 

Get conjugate.

void BaseType::convertXML   [virtual, inherited]
 

Convert XML data to internal format prior to serialization.

This method is currently only called by the XML parser for Object classes. If another BaseType class requires this method, a call must be added to the appropriate XML handler in the parser.

void Quat::get Matrix3   m const
 

Get the equivalent matrix for this quaternion.

void Quat::getEulerAngles double &    roll,
double &    pitch,
double &    yaw
const
 

Matrix3 Quat::getMatrix3   const [inline]
 

Get the equivalent matrix for this quaternion.

void Quat::getRotate double &    angle,
Vector3   vec
const
 

Return the angle and vector represented by the quaternion.

void Quat::getRotate double &    angle,
double &    x,
double &    y,
double &    z
const
 

Return the angle and vector components represented by the quaternion.

const Quat Quat::inverse   const [inline]
 

Multiplicative inverse method: q^(-1) = q^*/(q.q^*).

Quat Quat::invrotate const Quat &    q const [inline]
 

Rotate another quaternion by the inverse of this quaternion.

Vector3 Quat::invrotate const Vector3   v const
 

Rotate a vector by the inverse of this quaternion.

double Quat::length   const [inline]
 

Length of the quaternion = sqrt(vec . vec).

double Quat::length2   const [inline]
 

Squared length of the quaternion = vec . vec.

void Quat::makeRotate double    roll,
double    pitch,
double    yaw
 

Set this Quat to represent a rotation defined by Euler angles.

Parameters:
roll  The x-axis rotation angle (right-handed) in radians.
pitch  The y-axis rotation angle (right-handed) in radians.
yaw  The z-axis rotation angle (right-handed) in radians.

void Quat::makeRotate const Vector3   vec1,
const Vector3   vec2
 

Set this Quat to represent a rotation that transforms vec1 to vec2.

void Quat::makeRotate double    angle1,
const Vector3   axis1,
double    angle2,
const Vector3   axis2,
double    angle3,
const Vector3   axis3
 

Set this Quat to represent a product of three rotations.

Parameters:
angle1  the first rotation angle (right-handed) in radians.
axis1  the first rotation axis.
angle2  the second rotation angle (right-handed) in radians.
axis2  the second rotation axis.
angle3  the third rotation angle (right-handed) in radians.
axis3  the third rotation axis.

void Quat::makeRotate double    angle,
const Vector3   vec
 

Set this Quat to represent a rotation about an axis.

Parameters:
angle  the angle of rotation (right-handed) in radians.
vec  the rotation axis.

void Quat::makeRotate double    angle,
double    x,
double    y,
double    z
 

Set this Quat to represent a rotation about an axis.

Parameters:
angle  the angle of rotation (right-handed) in radians.
x  the x component of the rotation axis.
y  the y component of the rotation axis.
z  the z component of the rotation axis.

const Quat Quat::operator * const Quat &    rhs const [inline]
 

Binary multiply --- adjusted relative to osg for active transformations!

const Quat Quat::operator * double    rhs const [inline]
 

Multiply by scalar.

Quat& Quat::operator *= const Quat &    rhs [inline]
 

Unary multiply --- adjusted relative to osg for active transformations!

Quat& Quat::operator *= double    rhs [inline]
 

Unary multiply by scalar.

bool Quat::operator!= Quat const &    rhs const [inline]
 

Test inequality.

const Quat Quat::operator+ const Quat &    rhs const [inline]
 

Binary addition.

Quat& Quat::operator+= const Quat &    rhs [inline]
 

Unary addition.

const Quat Quat::operator-   const [inline]
 

Negation operator- returns the negative of the quaternion.

const Quat Quat::operator- const Quat &    rhs const [inline]
 

Binary subtraction.

Quat& Quat::operator-= const Quat &    rhs [inline]
 

Unary subtraction.

const Quat Quat::operator/ const Quat &    denom const [inline]
 

Binary divide.

const Quat Quat::operator/ double    rhs const [inline]
 

Divide by scalar.

Quat& Quat::operator/= const Quat &    denom [inline]
 

Unary divide.

Quat& Quat::operator/= double    rhs [inline]
 

Unary divide by scalar.

bool Quat::operator== Quat const &    rhs const [inline]
 

Test equality.

double Quat::operator[] int    i const [inline]
 

Get a component value by index (0,1,2,3 = x,y,z,w).

double& Quat::operator[] int    i [inline]
 

Access a component by index (0,1,2,3 = x,y,z,w).

Quat Quat::operator~   const [inline]
 

Get conjugate.

void Quat::parseXML const char *    cdata [virtual]
 

Internal method used by the XML parser.

The format for Quats is "X Y Z W"

Reimplemented from BaseType.

Quat Quat::rotate const Quat &    q const [inline]
 

Rotate another quaternion by this quaternion.

Vector3 Quat::rotate const Vector3   v const
 

Rotate a vector by this quaternion.

void Quat::serialize Archive   [virtual]
 

Serialize to or from a data archive.

Reimplemented from BaseType.

void Quat::set const Matrix3   m
 

Set quaternion to be equivalent to specified matrix.

void Quat::set double    x_,
double    y_,
double    z_,
double    w_
[inline]
 

Set the components.

void Quat::slerp double    t,
const Quat &    from,
const Quat &    to
 

Spherical Linear Interpolation.

As t goes from 0 to 1, the Quat object goes from "from" to "to".

virtual std::string Quat::typeString   const [inline, virtual]
 

Return a string representation of the type.

Implements BaseType.

double Quat::w   const [inline]
 

W component const accessor.

double& Quat::w   [inline]
 

W component accessor.

double Quat::x   const [inline]
 

X component const accessor.

double& Quat::x   [inline]
 

X component accessor.

double Quat::y   const [inline]
 

Y component const accessor.

double& Quat::y   [inline]
 

Y component accessor.

double Quat::z   const [inline]
 

Z component const accessor.

double& Quat::z   [inline]
 

Z component accessor.

bool Quat::zeroRotation   const [inline]
 

Test if the quaternion is zero.

Zero rotations can generally be ignored in computations.


Friends And Related Function Documentation

Quat operator * Vector3 const &    lhs,
Quat const &    rhs
[friend]
 

Multiply a Quat by a vector on the left.

Quat operator * Quat const &    lhs,
Vector3 const &    rhs
[friend]
 

Multiply a Quat by a vector on the right.

Quat operator * double    lhs,
const Quat &    rhs
[friend]
 

Multiply a Quat by a scalar value on the left.

std::ostream& operator<< std::ostream &    output,
const Quat &    quat
[friend]
 

Format to an output stream.


Member Data Documentation

NAMESPACE_SIMDATA const Quat Quat::IDENTITY [static]
 

The identity Quat = (0,0,0,1).

const Quat Quat::ZERO [static]
 

The zero Quat = (0,0,0,0).


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]