Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

openvrml::quatf Class Reference
[Base Types]

A quaternion. More...

List of all members.


Public Member Functions

 quatf () throw ()
 Default constructor.

 quatf (float x, float y, float z, float w) throw ()
 Construct from four values.

 quatf (const float(&quat)[4]) throw ()
 Construct from an array of four values.

 quatf (const rotation &rot) throw ()
 Construct from an rotation.

 quatf (const mat4f &mat) throw ()
 Construct from a rotation matrix.

quatfoperator *= (const quatf &quat) throw ()
 Multiply by a quaternion.

quatfoperator *= (float scalar) throw ()
 Multiply by a scalar.

quatfoperator/= (float scalar) throw ()
 Divide by a scalar.

quatfoperator+= (const quatf &quat) throw ()
 Add a quaternion.

quatfoperator-= (const quatf &quat) throw ()
 Subtract a quaternion.

const float & operator[] (size_t index) const throw ()
 Array element dereference operator (const version).

float & operator[] (size_t index) throw ()
 Array element dereference operator (non-const version).

float x () const throw ()
 Get the x component.

float y () const throw ()
 Get the y component.

float z () const throw ()
 Get the z component.

float w () const throw ()
 Get the w component.

void x (float value) throw ()
 Set the x component.

void y (float value) throw ()
 Set the y component.

void z (float value) throw ()
 Set the z component.

void w (float value) throw ()
 Set the w component.

const quatf conjugate () const throw ()
 Get the conjugate.

const quatf inverse () const throw ()
 Get the inverse.

float norm () const throw ()
 Get the norm.

const quatf normalize () const throw ()
 Normalize the quaternion.


Private Attributes

float quat [4]
 An array comprising the quaternion components.


Related Functions

(Note that these are not member functions.)

const quatf operator * (const quatf &lhs, const quatf &rhs) throw()
 Multiply two quaternions.

const quatf operator * (const quatf &quat, float scalar) throw()
 Multiply a quaternion by a scalar.

const quatf operator * (float scalar, const quatf &quat) throw()
 Multiply a scalar by a quaternion.

const quatf operator/ (const quatf &quat, float scalar) throw()
 Divide a quaternion by a scalar.

const quatf operator+ (const quatf &lhs, const quatf &rhs) throw()
 Add two quaternions.

const quatf operator- (const quatf &lhs, const quatf &rhs) throw()
 Take the difference between two quaternions.

std::ostream & operator<< (std::ostream &out, const quatf &quat)
 Stream output.

bool operator== (const quatf &lhs, const quatf &rhs) throw()
 Compare for equality.

bool operator!= (const quatf &lhs, const quatf &rhs) throw()
 Compare for inequality.


Detailed Description

A quaternion.


Constructor & Destructor Documentation

openvrml::quatf::quatf float  x,
float  y,
float  z,
float  w
throw ()
 

Construct from four values.

Parameters:
x the x vector component.
y the y vector component.
z the z vector component.
w the scalar value w.

openvrml::quatf::quatf const float &  quat[4]  )  throw () [explicit]
 

Construct from an array of four values.

Parameters:
quat the first three values in the array are used for the x, y, and z vector components, respectively. The fourth value in the array is used for the scalar part of the quaternion.

openvrml::quatf::quatf const rotation rot  )  throw () [explicit]
 

Construct from an rotation.

Parameters:
rot a rotation.

openvrml::quatf::quatf const mat4f mat  )  throw () [explicit]
 

Construct from a rotation matrix.

Parameters:
mat a rotation matrix.

Member Function Documentation

const quatf openvrml::quatf::conjugate  )  const throw ()
 

Get the conjugate.

Note:
q* = (-qv, qw)
Returns:
the conjugate of the quaternion.

const quatf openvrml::quatf::inverse  )  const throw ()
 

Get the inverse.

Note:
q-1 = q* / n(q)
Returns:
the multiplicative inverse.

float openvrml::quatf::norm  )  const throw ()
 

Get the norm.

Note:
n(q) = qx2 + qy2 + qz2 + qw2
Returns:
the norm.

const quatf openvrml::quatf::normalize  )  const throw ()
 

Normalize the quaternion.

Returns:
a unit quaternion derived from the quaternion.

quatf & openvrml::quatf::operator *= float  scalar  )  throw ()
 

Multiply by a scalar.

Parameters:
scalar value by which to multiply.
Returns:
a reference to the object.

quatf & openvrml::quatf::operator *= const quatf quat  )  throw ()
 

Multiply by a quaternion.

Note:
qr = (qv x rv + rwqv + qwrv, qwrw
  • qv . rv)
Parameters:
quat the quaternion by which to multiply.
Returns:
a reference to the object.

quatf & openvrml::quatf::operator+= const quatf quat  )  throw ()
 

Add a quaternion.

Parameters:
quat the quaternion to add.
Returns:
a reference to the object.

quatf & openvrml::quatf::operator-= const quatf quat  )  throw ()
 

Subtract a quaternion.

Parameters:
quat the quaternion to subtract.
Returns:
a reference to the object.

quatf & openvrml::quatf::operator/= float  scalar  )  throw ()
 

Divide by a scalar.

Parameters:
scalar value by which to divide.
Returns:
a reference to the object.

float & openvrml::quatf::operator[] size_t  index  )  throw () [inline]
 

Array element dereference operator (non-const version).

Parameters:
index an index from 0 - 3.
Precondition:
index is not larger than 3.

const float & openvrml::quatf::operator[] size_t  index  )  const throw () [inline]
 

Array element dereference operator (const version).

Parameters:
index an index from 0 - 3.
Precondition:
index is not larger than 3.

void openvrml::quatf::w float  value  )  throw () [inline]
 

Set the w component.

Parameters:
value w component value.

float openvrml::quatf::w  )  const throw () [inline]
 

Get the w component.

Returns:
the w component value.

void openvrml::quatf::x float  value  )  throw () [inline]
 

Set the x component.

Parameters:
value x component value.

float openvrml::quatf::x  )  const throw () [inline]
 

Get the x component.

Returns:
the x component value.

void openvrml::quatf::y float  value  )  throw () [inline]
 

Set the y component.

Parameters:
value y component value.

float openvrml::quatf::y  )  const throw () [inline]
 

Get the y component.

Returns:
the y component value.

void openvrml::quatf::z float  value  )  throw () [inline]
 

Set the z component.

Parameters:
value z component value.

float openvrml::quatf::z  )  const throw () [inline]
 

Get the z component.

Returns:
the z component value.

Friends And Related Function Documentation

const quatf operator * float  scalar,
const quatf quat
throw() [related]
 

Multiply a scalar by a quaternion.

Parameters:
scalar scalar.
quat quaternion.
Returns:
the product of scalar and quat.

const quatf operator * const quatf quat,
float  scalar
throw() [related]
 

Multiply a quaternion by a scalar.

Parameters:
quat quaternion.
scalar scalar.
Returns:
the product of quat and scalar.

const quatf operator * const quatf lhs,
const quatf rhs
throw() [related]
 

Multiply two quaternions.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
the product of lhs and rhs.

bool operator!= const quatf lhs,
const quatf rhs
throw() [related]
 

Compare for inequality.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
true if lhs and rhs are not equal; false otherwise.

const quatf operator+ const quatf lhs,
const quatf rhs
throw() [related]
 

Add two quaternions.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
the sum of lhs and rhs.

const quatf operator- const quatf lhs,
const quatf rhs
throw() [related]
 

Take the difference between two quaternions.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
the difference between lhs and rhs.

const quatf operator/ const quatf quat,
float  scalar
throw() [related]
 

Divide a quaternion by a scalar.

Parameters:
quat quaternion.
scalar scalar.
Returns:
the result of dividing quat by scalar.

std::ostream & operator<< std::ostream &  out,
const quatf quat
[related]
 

Stream output.

Parameters:
out an output stream.
quat a quaternion.
Returns:
out.

bool operator== const quatf lhs,
const quatf rhs
throw() [related]
 

Compare for equality.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
true if lhs and rhs are equal; false otherwise.

Member Data Documentation

float openvrml::quatf::quat[4] [private]
 

An array comprising the quaternion components.

For internal use only.