Class for representing a rotation (double precision). More...
#include <Inventor/SbRotation.h>
Public Member Functions | |
SbRotationd () | |
Constructor for rotation. | |
SbRotationd (const double v[4]) | |
Constructor. | |
SbRotationd (double q0, double q1, double q2, double q3) | |
Constructor. | |
SbRotationd (const SbMatrixd &m) | |
Constructor. | |
SbRotationd (const SbMatrix3 &m) | |
Constructor. | |
SbRotationd (const SbVec3d &axis, double radians) | |
Constructor. | |
SbRotationd (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) | |
Constructor. | |
const double * | getValue () const |
Returns pointer to array of 4 components defining quaternion. | |
void | getValue (double &q0, double &q1, double &q2, double &q3) const |
Returns 4 individual components of rotation quaternion. | |
void | getValue (SbVec3d &axis, double &radians) const |
Returns corresponding 3D rotation axis vector and angle in radians. | |
void | getValue (SbMatrixd &matrix) const |
Returns corresponding 4x4 rotation matrix. | |
void | getValue (SbMatrix &matrix) const |
Returns corresponding 4x4 rotation matrix. | |
void | getValue (SbMatrix3 &matrix) const |
Returns corresponding 3x3 rotation matrix. | |
SbRotationd & | invert () |
Changes a rotation to be its inverse. | |
SbRotationd | inverse () const |
Returns the inverse of a rotation. | |
SbRotationd & | setValue (const double q[4]) |
Sets value of rotation from array of 4 components of a quaternion. | |
SbRotationd & | setValue (double q0, double q1, double q2, double q3) |
Sets value of rotation from 4 individual components of a quaternion. | |
SbRotationd & | setValue (const SbMatrixd &m) |
Sets value of rotation from a rotation matrix. | |
SbRotationd & | setValue (const SbVec3d &axis, double radians) |
Sets value of vector from 3D rotation axis vector and angle in radians. | |
SbRotationd & | setValue (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) |
Sets rotation to rotate one direction vector to another. | |
SbRotationd & | setValue (const SbRotation &rotate) |
Sets rotation from a single precision rotation. | |
SbRotationd & | setValue (const SbMatrix &m) |
Sets rotation from a single precision rotation matrix. | |
SbRotationd & | setValue (const SbMatrix3 &m) |
Sets rotation from a 3x3 rotation matrix. | |
SbRotationd & | operator*= (const SbRotationd &q) |
Multiplies by another rotation; results in product of rotations. | |
SbBool | equals (const SbRotationd &r, double tolerance) const |
Equality comparison within given tolerance - the square of the length of the maximum distance between the two quaternion vectors. | |
void | multVec (const SbVec3d &src, SbVec3d &dst) const |
Multiplies the given vector by the matrix of this rotation. | |
void | scaleAngle (double scaleFactor) |
Keep the axis the same. | |
Static Public Member Functions | |
static SbRotationd | slerp (const SbRotationd &rot0, const SbRotationd &rot1, double t) |
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1. | |
static SbRotationd | identity () |
Returns a null rotation. | |
Friends | |
int | operator== (const SbRotationd &q1, const SbRotationd &q2) |
Equality comparison operator. | |
int | operator!= (const SbRotationd &q1, const SbRotationd &q2) |
Inequality comparison operator. | |
SbRotationd | operator* (const SbRotationd &q1, const SbRotationd &q2) |
Multiplication of two rotations; results in product of rotations. | |
Class for representing a rotation (double precision).
Object that stores a rotation using double precision values. Although Open Inventor fields still store only single precision values, for certain applications it is useful and convenient to be able to store and manipulate double precision values, for example, double precision coordinate data or values that will be used for further computation.
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 double values, when intending to set an axis and angle. The methods that take four double values directly specify the quaternion value, which is probably not the intended result.
For example:
SbRotation, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us
Definition at line 425 of file SbRotation.h.
|
inline |
Constructor for rotation.
The initial value is no rotation.
Definition at line 431 of file SbRotation.h.
|
inline |
Constructor.
The constructors that take four doubles create a quaternion from those doubles (careful, this differs from the four numbers in an axis/radian definition).
Definition at line 439 of file SbRotation.h.
|
inline |
Constructor.
The constructors that take four doubles create a quaternion from those doubles (careful, this differs from the four numbers in an axis/radian definition).
Definition at line 447 of file SbRotation.h.
|
inline |
Constructor.
The matrix constructor requires a valid rotation matrix.
Definition at line 454 of file SbRotation.h.
|
inline |
Constructor.
The matrix constructor requires a valid 3x3 rotation matrix.
Definition at line 461 of file SbRotation.h.
|
inline |
Constructor.
The axis/radians constructor creates a rotation of angle radians about the given axis.
Definition at line 468 of file SbRotation.h.
Constructor.
The rotateFrom/To constructor defines 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 477 of file SbRotation.h.
SbBool SbRotationd::equals | ( | const SbRotationd & | r, |
double | 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 483 of file SbRotation.h.
void SbRotationd::getValue | ( | double & | q0, |
double & | q1, | ||
double & | q2, | ||
double & | q3 | ||
) | const |
Returns 4 individual components of rotation quaternion.
void SbRotationd::getValue | ( | SbMatrix & | matrix | ) | const |
Returns corresponding 4x4 rotation matrix.
void SbRotationd::getValue | ( | SbMatrix3 & | matrix | ) | const |
Returns corresponding 3x3 rotation matrix.
void SbRotationd::getValue | ( | SbMatrixd & | matrix | ) | const |
Returns corresponding 4x4 rotation matrix.
void SbRotationd::getValue | ( | SbVec3d & | axis, |
double & | radians | ||
) | const |
Returns corresponding 3D rotation axis vector and angle in radians.
|
inlinestatic |
Returns a null rotation.
Definition at line 617 of file SbRotation.h.
|
inline |
Returns the inverse of a rotation.
Definition at line 525 of file SbRotation.h.
SbRotationd & SbRotationd::invert | ( | ) |
Changes a rotation to be its inverse.
Multiplies the given vector by the matrix of this rotation.
SbRotationd & SbRotationd::operator*= | ( | const SbRotationd & | q | ) |
Multiplies by another rotation; results in product of rotations.
void SbRotationd::scaleAngle | ( | double | scaleFactor | ) |
Keep the axis the same.
Multiply the angle of rotation by the amount scaleFactor.
SbRotationd & SbRotationd::setValue | ( | const double | q[4] | ) |
Sets value of rotation from array of 4 components of a quaternion.
SbRotationd & SbRotationd::setValue | ( | const SbMatrix & | m | ) |
Sets rotation from a single precision rotation matrix.
SbRotationd & SbRotationd::setValue | ( | const SbMatrix3 & | m | ) |
Sets rotation from a 3x3 rotation matrix.
SbRotationd & SbRotationd::setValue | ( | const SbMatrixd & | m | ) |
Sets value of rotation from a rotation matrix.
SbRotationd & SbRotationd::setValue | ( | const SbRotation & | rotate | ) |
Sets rotation from a single precision rotation.
SbRotationd & SbRotationd::setValue | ( | const SbVec3d & | axis, |
double | radians | ||
) |
Sets value of vector from 3D rotation axis vector and angle in radians.
SbRotationd & SbRotationd::setValue | ( | const SbVec3d & | rotateFrom, |
const SbVec3d & | rotateTo | ||
) |
Sets rotation to rotate one direction vector to another.
The rotateFrom and rotateTo arguments are normalized before the rotation is calculated.
SbRotationd & SbRotationd::setValue | ( | double | q0, |
double | q1, | ||
double | q2, | ||
double | 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 582 of file SbRotation.h.
|
friend |
Multiplication of two rotations; results in product of rotations.
|
friend |
Equality comparison operator.