SbRotation Class Reference
[Basics]

Class for representing a rotation. More...

#include <Inventor/SbRotation.h>

List of all members.

Public Member Functions

 SbRotation ()
 SbRotation (const float v[4])
 SbRotation (float q0, float q1, float q2, float q3)
 SbRotation (const SbMatrix &m)
 SbRotation (const SbMatrix3 &m)
 SbRotation (const SbVec3f &axis, float radians)
 SbRotation (const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
const float * getValue () const
void getValue (float &q0, float &q1, float &q2, float &q3) const
void getValue (SbVec3f &axis, float &radians) const
void getValue (SbMatrix &matrix) const
void getValue (SbMatrix3 &matrix) const
void getValue (SbMatrixd &matrix) const
SbRotationinvert ()
SbRotation inverse () const
SbRotationsetValue (const float q[4])
SbRotationsetValue (float q0, float q1, float q2, float q3)
SbRotationsetValue (const SbMatrix &m)
SbRotationsetValue (const SbMatrix3 &m)
SbRotationsetValue (const SbVec3f &axis, float radians)
SbRotationsetValue (const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
SbRotationsetValue (const SbRotationd &rotated)
SbRotationsetValue (const SbMatrixd &md)
SbRotationoperator*= (const SbRotation &q)
SbBool equals (const SbRotation &r, float tolerance) const
void multVec (const SbVec3f &src, SbVec3f &dst) const
void scaleAngle (float scaleFactor)

Static Public Member Functions

static SbRotation slerp (const SbRotation &rot0, const SbRotation &rot1, float t)
static SbRotation identity ()

Friends

int operator== (const SbRotation &q1, const SbRotation &q2)
int operator!= (const SbRotation &q1, const SbRotation &q2)
SbRotation operator* (const SbRotation &q1, const SbRotation &q2)

Detailed Description

Class for representing a rotation.

Object that stores a rotation. There are several ways to specify a rotation: quaternion (4 floats, in the order x, y, z, w), 4x4 rotation matrix, or axis and angle. All angles are in radians and all rotations are right-handed.

The rotation value is stored internally as a quaternion. Quaternion representation is more compact, faster to compute and more numerically stable than rotation matrices. Quaternion representation allows smooth rotation (spherical linear interpolation) and avoids the problem of "gimbal lock" associated with Euler angles. It is not necessary to deal directly with quaternions. Many convenience methods are provided to set and get rotations using matrix and axis/angle representations.

Rotations are most commonly specified using an axis and an angle in radians. A common mistake is to use the constructor or setValue method that takes four float values, when intending to set an axis and angle. The methods that take four float values directly specify the quaternion value, which is probably not the intended result. For example:

     // Create a rotation of PI/2 radians around the Z axis:

     // Incorrect.
     // (Compiles, but actually sets the quaternion value directly!)
     SbRotation rotation(0, 0, 1, 1.5707963f);

     // This is the correct rotation.
     SbRotation rotation( SbVec3f(0, 0, 1), 1.5707963f);

SEE ALSO

SbRotationd, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us


Constructor & Destructor Documentation

SbRotation::SbRotation (  )  [inline]

Default constructor.

The initial value is no rotation.

SbRotation::SbRotation ( const float  v[4]  )  [inline]

Constructor.

The quaternion constructor takes four floats that define a quaternion.
Note this is NOT the same as an axis/radian definition.

SbRotation::SbRotation ( float  q0,
float  q1,
float  q2,
float  q3 
) [inline]

Constructor.

The quaternion constructor takes four floats that define a quaternion.
Note this is NOT the same as an axis/radian definition.

SbRotation::SbRotation ( const SbMatrix m  )  [inline]

Constructor.

The matrix constructor takes a valid rotation matrix.

SbRotation::SbRotation ( const SbMatrix3 m  )  [inline]

Constructor.

The matrix constructor takes a valid 3x3 rotation matrix.

SbRotation::SbRotation ( const SbVec3f axis,
float  radians 
) [inline]

Constructor.

The axis/radians constructor creates a rotation of angle radians about the given axis.

SbRotation::SbRotation ( const SbVec3f rotateFrom,
const SbVec3f rotateTo 
) [inline]

Constructor.

The rotateFrom/To constructor defines a rotation that rotates from one vector into another. The rotateFrom and rotateTo vectors are normalized by the constructor before calculating the rotation.


Member Function Documentation

SbBool SbRotation::equals ( const SbRotation r,
float  tolerance 
) const

Equality comparison within given tolerance - the square of the length of the maximum distance between the two quaternion vectors.

void SbRotation::getValue ( SbMatrixd matrix  )  const

Returns corresponding 4x4 rotation matrix.

void SbRotation::getValue ( SbMatrix3 matrix  )  const

Returns corresponding 3x3 rotation matrix.

void SbRotation::getValue ( SbMatrix matrix  )  const

Returns corresponding 4x4 rotation matrix.

void SbRotation::getValue ( SbVec3f axis,
float &  radians 
) const

Returns corresponding 3D rotation axis vector and angle in radians.

void SbRotation::getValue ( float &  q0,
float &  q1,
float &  q2,
float &  q3 
) const

Returns 4 individual components of rotation quaternion.

const float* SbRotation::getValue (  )  const [inline]

Returns pointer to array of 4 components defining quaternion.

static SbRotation SbRotation::identity (  )  [inline, static]

Returns a null rotation.

SbRotation SbRotation::inverse (  )  const [inline]

Returns the inverse of a rotation.

SbRotation& SbRotation::invert (  ) 

Changes a rotation to be its inverse.

void SbRotation::multVec ( const SbVec3f src,
SbVec3f dst 
) const

Multiplies the given vector by the matrix of this rotation.

SbRotation& SbRotation::operator*= ( const SbRotation q  ) 

Multiplies by another rotation; results in product of rotations.

void SbRotation::scaleAngle ( float  scaleFactor  ) 

Keep the axis the same.

Multiply the angle of rotation by the amount scaleFactor.

SbRotation& SbRotation::setValue ( const SbMatrixd md  ) 

Sets rotation from a double precision rotation matrix.

SbRotation& SbRotation::setValue ( const SbRotationd rotated  ) 

Sets rotation from a double precision rotation.

SbRotation& SbRotation::setValue ( const SbVec3f rotateFrom,
const SbVec3f rotateTo 
)

Sets rotation to rotate one direction vector to another.

The rotateFrom and rotateTo arguments are normalized before the rotation is calculated.

SbRotation& SbRotation::setValue ( const SbVec3f axis,
float  radians 
)

Sets value of vector from 3D rotation axis vector and angle in radians.

SbRotation& SbRotation::setValue ( const SbMatrix3 m  ) 

Sets rotation from a 3x3 rotation matrix.

SbRotation& SbRotation::setValue ( const SbMatrix m  ) 

Sets value of rotation from a rotation matrix.

SbRotation& SbRotation::setValue ( float  q0,
float  q1,
float  q2,
float  q3 
)

Sets value of rotation from 4 individual components of a quaternion.

SbRotation& SbRotation::setValue ( const float  q[4]  ) 

Sets value of rotation from array of 4 components of a quaternion.

static SbRotation SbRotation::slerp ( const SbRotation rot0,
const SbRotation rot1,
float  t 
) [static]

Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.


Friends And Related Function Documentation

int operator!= ( const SbRotation q1,
const SbRotation q2 
) [friend]

Inequality comparison operator.

SbRotation operator* ( const SbRotation q1,
const SbRotation q2 
) [friend]

Multiplication of two rotations; results in product of rotations.

int operator== ( const SbRotation q1,
const SbRotation q2 
) [friend]

Equality comparison operator.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/