Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Quaternion Class Reference

Defines a Quaternion consisting of W, X, Y and Z components. More...

#include <Quaternion.h>

List of all members.

Public Member Functions

 Quaternion ()
 Default constructor, initializes all components to 0.

 Quaternion (float w, float x, float y, float z)
 Initializes the components to the specified values.

 Quaternion (float angle, const Vector &axis)
 Fills in the quaternion to represent the rotation determined by the specified angle around the specified axis.

float & operator[] (int which)
 Mutable accessor for a Quaternion component.

float operator[] (int which) const
 Immutable accessor for a Quaternion component.

const Quaternion normalize () const
 Normalize the Quaternion: divide all components by the Quaternion length.

float length () const
 Returns the length of the Quaternion.

const Matrix toMatrix () const
 Returns the rotation matrix represented by this quaternion.


Static Public Attributes

const int W = 0
 The W coordinate index in the array representing this Quaternion.

const int X = 1
 The X coordinate index in the array representing this Quaternion.

const int Y = 2
 The Y coordinate index in the array representing this Quaternion.

const int Z = 3
 The Z coordinate index in the array representing this Quaternion.


Private Member Functions

void initialize (float w, float x, float y, float z)
 Initialize the components to the specified values.


Private Attributes

float m_data [4]
 The data array containing the W, X, Y and Z values.


Friends

std::ostream & operator<< (std::ostream &out, const Quaternion &quat)
 Insertion operator for this Quaternion into an output stream.


Detailed Description

Defines a Quaternion consisting of W, X, Y and Z components.


Constructor & Destructor Documentation

Quaternion::Quaternion float  angle,
const Vector axis
 

Fills in the quaternion to represent the rotation determined by the specified angle around the specified axis.

The quaternion is initialized as follows:

  • w = cos(angle / 2)
  • (x, y, z) = axis * sin(angle / 2)


Member Function Documentation

float Quaternion::length  )  const
 

Returns the length of the Quaternion.

The length is computed by taking the square root of the sum of the squares of the Quaternion components.


The documentation for this class was generated from the following files:
Generated on Mon Aug 25 23:40:58 2003 for Shadow by doxygen 1.3.2