Class for representing a rotation. More...
#include <Inventor/SbRotation.h>
Public Member Functions | |
SbRotation () | |
Default constructor. | |
SbRotation (const float v[4]) | |
Constructor. | |
SbRotation (float q0, float q1, float q2, float q3) | |
Constructor. | |
SbRotation (const SbMatrix &m) | |
Constructor. | |
SbRotation (const SbMatrix3 &m) | |
Constructor. | |
SbRotation (const SbVec3f &axis, float radians) | |
Constructor. | |
SbRotation (const SbVec3f &rotateFrom, const SbVec3f &rotateTo) | |
Constructor. | |
const float * | getValue () const |
Returns pointer to array of 4 components defining quaternion. | |
void | getValue (float &q0, float &q1, float &q2, float &q3) const |
Returns 4 individual components of rotation quaternion. | |
void | getValue (SbVec3f &axis, float &radians) const |
Returns corresponding 3D rotation axis vector and angle in radians. | |
void | getValue (SbMatrix &matrix) const |
Returns corresponding 4x4 rotation matrix. | |
void | getValue (SbMatrix3 &matrix) const |
Returns corresponding 3x3 rotation matrix. | |
void | getValue (SbMatrixd &matrix) const |
Returns corresponding 4x4 rotation matrix. | |
SbRotation & | invert () |
Changes a rotation to be its inverse. | |
SbRotation | inverse () const |
Returns the inverse of a rotation. | |
SbRotation & | setValue (const float q[4]) |
Sets value of rotation from array of 4 components of a quaternion. | |
SbRotation & | setValue (float q0, float q1, float q2, float q3) |
Sets value of rotation from 4 individual components of a quaternion. | |
SbRotation & | setValue (const SbMatrix &m) |
Sets value of rotation from a rotation matrix. | |
SbRotation & | setValue (const SbMatrix3 &m) |
Sets rotation from a 3x3 rotation matrix. | |
SbRotation & | setValue (const SbVec3f &axis, float radians) |
Sets value of vector from 3D rotation axis vector and angle in radians. | |
SbRotation & | setValue (const SbVec3f &rotateFrom, const SbVec3f &rotateTo) |
Sets rotation to rotate one direction vector to another. | |
SbRotation & | setValue (const SbRotationd &rotated) |
Sets rotation from a double precision rotation. | |
SbRotation & | setValue (const SbMatrixd &md) |
Sets rotation from a double precision rotation matrix. | |
SbRotation & | operator*= (const SbRotation &q) |
Multiplies by another rotation; results in product of rotations. | |
SbBool | 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 | multVec (const SbVec3f &src, SbVec3f &dst) const |
Multiplies the given vector by the matrix of this rotation. | |
void | scaleAngle (float scaleFactor) |
Keep the axis the same. | |
Static Public Member Functions | |
static SbRotation | slerp (const SbRotation &rot0, const SbRotation &rot1, float t) |
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1. | |
static SbRotation | identity () |
Returns a null rotation. | |
Friends | |
int | operator== (const SbRotation &q1, const SbRotation &q2) |
Equality comparison operator. | |
int | operator!= (const SbRotation &q1, const SbRotation &q2) |
Inequality comparison operator. | |
SbRotation | operator* (const SbRotation &q1, const SbRotation &q2) |
Multiplication of two rotations; results in product of rotations. | |
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:
SbRotationd, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us
Definition at line 126 of file SbRotation.h.
|
inline |
|
inline |
Constructor.
The quaternion constructor takes four floats that define a quaternion.
Note this is NOT the same as an axis/radian definition.
Definition at line 140 of file SbRotation.h.
|
inline |
Constructor.
The quaternion constructor takes four floats that define a quaternion.
Note this is NOT the same as an axis/radian definition.
Definition at line 148 of file SbRotation.h.
|
inline |
Constructor.
The matrix constructor takes a valid rotation matrix.
Definition at line 155 of file SbRotation.h.
|
inline |
Constructor.
The matrix constructor takes a valid 3x3 rotation matrix.
Definition at line 162 of file SbRotation.h.
|
inline |
Constructor.
The axis/radians constructor creates a rotation of angle radians about the given axis.
Definition at line 169 of file SbRotation.h.
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.
Definition at line 178 of file SbRotation.h.
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.
|
inline |
Returns pointer to array of 4 components defining quaternion.
Definition at line 184 of file SbRotation.h.
void SbRotation::getValue | ( | float & | q0, |
float & | q1, | ||
float & | q2, | ||
float & | q3 | ||
) | const |
Returns 4 individual components of rotation quaternion.
void SbRotation::getValue | ( | SbMatrix & | matrix | ) | const |
Returns corresponding 4x4 rotation matrix.
void SbRotation::getValue | ( | SbMatrix3 & | matrix | ) | const |
Returns corresponding 3x3 rotation matrix.
void SbRotation::getValue | ( | SbMatrixd & | 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.
|
inlinestatic |
Returns a null rotation.
Definition at line 318 of file SbRotation.h.
|
inline |
Returns the inverse of a rotation.
Definition at line 226 of file SbRotation.h.
SbRotation & SbRotation::invert | ( | ) |
Changes a rotation to be its inverse.
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 float | q[4] | ) |
Sets value of rotation from array of 4 components of a quaternion.
SbRotation & SbRotation::setValue | ( | const SbMatrix & | m | ) |
Sets value of rotation from a rotation matrix.
SbRotation & SbRotation::setValue | ( | const SbMatrix3 & | m | ) |
Sets rotation from a 3x3 rotation matrix.
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 & | axis, |
float | radians | ||
) |
Sets value of vector from 3D rotation axis vector and angle in radians.
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 | ( | float | q0, |
float | q1, | ||
float | q2, | ||
float | q3 | ||
) |
Sets value of rotation from 4 individual components of a quaternion.
|
static |
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
|
friend |
Inequality comparison operator.
Definition at line 283 of file SbRotation.h.
|
friend |
Multiplication of two rotations; results in product of rotations.
|
friend |
Equality comparison operator.