Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

SFRotation Class Reference

Encapsulates an SFRotation. More...

Inheritance diagram for SFRotation:

FieldValue List of all members.

Public Types

typedef const float (&ConstArrayReference)[4]
typedef float(* ArrayPointer )[4]
typedef const float(* ConstArrayPointer )[4]

Public Methods

typedef float (&ArrayReference)[4]
 SFRotation () throw ()
 Default constructor.

 SFRotation (ConstArrayReference rot) throw ()
 Constructor.

 SFRotation (float x, float y, float z, float angle) throw ()
 Constructor.

 SFRotation (const SFVec3f &axis, float angle) throw ()
 Constructor.

 SFRotation (const SFVec3f &fromVec, const SFVec3f &toVec) throw ()
 Construct a rotation between two vectors.

virtual ~SFRotation () throw ()
 Destructor.

ConstArrayReference get () const throw ()
 Get the value of this rotation.

void set (ConstArrayReference rot) throw ()
 Set the value of this rotation.

float getX () const throw ()
 Get the x-component of the rotation axis.

void setX (float value) throw ()
 Set the x-component of the rotation axis.

float getY () const throw ()
 Get the y-component of the rotation axis.

void setY (float value) throw ()
 Set the y-component of the rotation axis.

float getZ () const throw ()
 Get the z-component of the rotation axis.

void setZ (float value) throw ()
 Set the z-component of the rotation axis.

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

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

const SFVec3f getAxis () const throw ()
 Get the axis of rotation as a SFVec3f.

void setAxis (const SFVec3f &vec) throw ()
 Set the axis of rotation using a SFVec3f.

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

const SFRotation multiply (const SFRotation &rot) const throw ()
 Multiply two rotations.

const SFVec3f multVec (const SFVec3f &vec) const
 Multiply the matrix corresponding to this rotation by a vector.

const SFRotation slerp (const SFRotation &destRot, float t) const throw ()
 Perform a Spherical Linear IntERPolation.

virtual std::auto_ptr< FieldValueclone () const throw (std::bad_alloc)
 Virtual copy constructor.

virtual FieldValueassign (const FieldValue &value) throw (std::bad_cast)
 Virtual assignment.

virtual Type type () const throw ()
 Get the FieldValue::Type associated with this class.


Private Methods

virtual void print (std::ostream &os) const
 Print to an output stream.


Private Attributes

float value [4]

Detailed Description

Encapsulates an SFRotation.

Per the VRML97 specification, the axis of an SFRotation is a normalized vector (5.8). The specification leaves undefined how to deal with an attempt to construct an SFRotation from an axis vector that is not normalized. In order to allow users of the library to minimize the number of normalizations, OpenVRML takes the following approach:


Constructor & Destructor Documentation

SFRotation   throw ()
 

Default constructor.

Construct with the default value, (0, 0, 1, 0).

SFRotation ConstArrayReference    rot throw () [explicit]
 

Constructor.

Parameters:
rot a 4-element array.
Precondition:
The first three elements of the argument array constitute a normalized vector.

SFRotation float    x,
float    y,
float    z,
float    angle
throw ()
 

Constructor.

Parameters:
x the x-component of the axis of rotation
y the y-component of the axis of rotation
z the z-component of the axis of rotation
angle the rotation angle
Precondition:
The first three arguments constitute a normalized vector.

SFRotation const SFVec3f   axis,
float    angle
throw ()
 

Constructor.

Parameters:
axis a normalized vector to use as the axis of rotation
angle the rotation angle
Precondition:
The first argument is a normalized vector.

SFRotation const SFVec3f   fromVector,
const SFVec3f   toVector
throw ()
 

Construct a rotation between two vectors.

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

Parameters:
fromVector the starting vector
toVector the ending vector

~SFRotation   throw () [virtual]
 

Destructor.


Member Function Documentation

FieldValue & assign const FieldValue   value throw (std::bad_cast) [virtual]
 

Virtual assignment.

Parameters:
value the new value to give the object.
Returns:
a reference to the object.
Exceptions:
std::bad_cast if value is not an SFRotation.

Implements FieldValue.

std::auto_ptr< FieldValue > clone   const throw (std::bad_alloc) [virtual]
 

Virtual copy constructor.

Returns:
a pointer to a copy of the object.
Exceptions:
std::bad_alloc if memory allocation fails.

Implements FieldValue.

SFRotation::ConstArrayReference get   const throw ()
 

Get the value of this rotation.

Returns:
a reference to a 4-element array.

float getAngle   const throw ()
 

Get the rotation angle.

Returns:
the rotation angle.

const SFVec3f getAxis   const throw ()
 

Get the axis of rotation as a SFVec3f.

Returns:
the axis of rotation

float getX   const throw ()
 

Get the x-component of the rotation axis.

Returns:
the x-component of the rotation axis.

float getY   const throw ()
 

Get the y-component of the rotation axis.

Returns:
the y-component of the rotation axis.

float getZ   const throw ()
 

Get the z-component of the rotation axis.

Returns:
the z-component of the rotation axis.

const SFRotation inverse   const throw ()
 

Get the inverse.

Returns:
a SFRotation that is the inverse of this one.

const SFRotation multiply const SFRotation &    rot const throw ()
 

Multiply two rotations.

Parameters:
rot the rotation by which to multiply this one.
Returns:
the result rotation.

const SFVec3f multVec const SFVec3f   vec const
 

Multiply the matrix corresponding to this rotation by a vector.

Todo:
IMPLEMENT ME!
Parameters:
vec vector by which to multiply this rotation.
Returns:
the result of multiplying this rotation by vec.

void print std::ostream &    out const [private, virtual]
 

Print to an output stream.

Parameters:
out an output stream.

Implements FieldValue.

void set ConstArrayReference    rot throw ()
 

Set the value of this rotation.

Parameters:
rot a 4-element array
Precondition:
The first three elements of rot constitute a normalized vector.

void setAngle float    value throw ()
 

Set the rotation angle.

Parameters:
value 

void setAxis const SFVec3f   axis throw ()
 

Set the axis of rotation using a SFVec3f.

Parameters:
axis the new rotation axis.
Precondition:
axis is a normalized vector.

void setX float    value throw ()
 

Set the x-component of the rotation axis.

Parameters:
value 

void setY float    value throw ()
 

Set the y-component of the rotation axis.

Parameters:
value 

void setZ float    value throw ()
 

Set the z-component of the rotation axis.

Parameters:
value 

const SFRotation slerp const SFRotation &    destRotation,
float    t
const throw ()
 

Perform a Spherical Linear IntERPolation.

Parameters:
destRotation the destination rotation
t the interval fraction

FieldValue::Type type   const throw () [virtual]
 

Get the FieldValue::Type associated with this class.

Returns:
FieldValue::sfrotation.

Implements FieldValue.