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

openvrml::rotation Class Reference
[Base Types]

A rotation. More...

List of all members.


Public Member Functions

 rotation () throw ()
 Construct.

 rotation (const float(&rot)[4]) throw ()
 Construct from an array.

 rotation (float x, float y, float z, float angle) throw ()
 Construct from x, y, z, and angle components.

 rotation (const vec3f &axis, float angle) throw ()
 Construct from an axis vector and an angle.

 rotation (const vec3f &from_vec, const vec3f &to_vec) throw ()
 Construct a rotation between two vectors.

 rotation (const quatf &quat) throw ()
 Construct from a quaternion.

rotationoperator *= (const rotation &rot) throw ()
 Multiply rotations.

const float & operator[] (size_t index) const throw ()
 Index-based element access.

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

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

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

const vec3f axis () const throw ()
 Get the axis of rotation.

float angle () const throw ()
 Get the rotation angle.

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

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

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

void axis (const vec3f &axis) throw ()
 Set the axis of rotation.

void angle (float value) throw ()
 Set the rotation angle.

const rotation inverse () const throw ()
 Inverse rotation.

const rotation slerp (const rotation &dest_rot, float t) const throw ()
 Spherical Linear intERPolation.


Private Attributes

float rot [4]
 Rotation components.


Related Functions

(Note that these are not member functions.)

const rotation operator * (const rotation &lhs, const rotation &rhs) throw()
 Multiply rotations.

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

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

std::ostream & operator<< (std::ostream &out, const rotation &r)
 Stream output.


Detailed Description

A rotation.

VRML rotations are represented with four single precision floating point components. The first three are an axis of rotation, and the last is rotation in radians.


Constructor & Destructor Documentation

openvrml::rotation::rotation const float &  rot[4]  )  throw () [explicit]
 

Construct from an array.

Parameters:
rot an array comprising the rotation components.
Precondition:
The vector represented by the first three components of rot is normalized.

openvrml::rotation::rotation float  x,
float  y,
float  z,
float  angle
throw ()
 

Construct from x, y, z, and angle components.

Parameters:
x x-component of the rotation axis.
y y-component of the rotation axis.
z z-component of the rotation axis.
angle rotation angle.
Precondition:
The vector represented by x, y, and z is normalized.

openvrml::rotation::rotation const vec3f axis,
float  angle
throw ()
 

Construct from an axis vector and an angle.

Parameters:
axis rotation axis.
angle rotation angle.
Precondition:
axis is a normalized vector.

openvrml::rotation::rotation const vec3f from_vec,
const vec3f to_vec
throw ()
 

Construct a rotation between two vectors.

Construct a rotation equal to the rotation between two different vectors.

Parameters:
from_vec the starting vector.
to_vec the ending vector.

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

Construct from a quaternion.

Parameters:
quat a quaternion.

Member Function Documentation

void openvrml::rotation::angle float  value  )  throw () [inline]
 

Set the rotation angle.

Parameters:
value new rotation angle value.

float openvrml::rotation::angle  )  const throw () [inline]
 

Get the rotation angle.

Returns:
the rotation angle.

void openvrml::rotation::axis const vec3f axis  )  throw ()
 

Set the axis of rotation.

Parameters:
axis new axis of rotation.

const vec3f openvrml::rotation::axis  )  const throw () [inline]
 

Get the axis of rotation.

Returns:
the axis of rotation.

const rotation openvrml::rotation::inverse  )  const throw () [inline]
 

Inverse rotation.

Returns:
the inverse rotation.

rotation & openvrml::rotation::operator *= const rotation rot  )  throw ()
 

Multiply rotations.

Parameters:
rot the rotation by which to multiply.
Returns:
a reference to the object.

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

Index-based element access.

Parameters:
index 0 is the x axis component, 1 is the y axis component, 2 is the z axis component, and 3 is the angle.

const rotation openvrml::rotation::slerp const rotation dest_rot,
float  t
const throw ()
 

Spherical Linear intERPolation.

Parameters:
dest_rot destination rotation.
t fraction representing the desired position between the rotation and dest_rot.
Returns:
the rotation corresponding to t between the rotation and dest_rot.

void openvrml::rotation::x float  value  )  throw ()
 

Set the x axis component.

Parameters:
value new x axis component value.

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

Get the x axis component.

Returns:
the x axis component.

void openvrml::rotation::y float  value  )  throw ()
 

Set the y axis component.

Parameters:
value new y axis component value.

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

Get the y axis component.

Returns:
the y axis component.

void openvrml::rotation::z float  value  )  throw ()
 

Set the z axis component.

Parameters:
value new z axis component value.

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

Get the z axis component.

Returns:
the z axis component.

Friends And Related Function Documentation

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

Multiply rotations.

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

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

Compare for inequality.

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

std::ostream & operator<< std::ostream &  out,
const rotation r
[related]
 

Stream output.

Parameters:
out output stream.
r a rotation.
Returns:
out.

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

Compare for equality.

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

Member Data Documentation

float openvrml::rotation::rot[4] [private]
 

Rotation components.

For internal use only.

The first three components define an axis through the origin. The fourth component is a rotation around the axis.