Class for representing a rotation (double precision). More...
#include <Inventor/SbRotation.h>
Public Member Functions | |
SbRotationd () | |
SbRotationd (const double v[4]) | |
SbRotationd (double q0, double q1, double q2, double q3) | |
SbRotationd (const SbMatrixd &m) | |
SbRotationd (const SbMatrix3 &m) | |
SbRotationd (const SbVec3d &axis, double radians) | |
SbRotationd (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) | |
const double * | getValue () const |
void | getValue (double &q0, double &q1, double &q2, double &q3) const |
void | getValue (SbVec3d &axis, double &radians) const |
void | getValue (SbMatrixd &matrix) const |
void | getValue (SbMatrix &matrix) const |
void | getValue (SbMatrix3 &matrix) const |
SbRotationd & | invert () |
SbRotationd | inverse () const |
SbRotationd & | setValue (const double q[4]) |
SbRotationd & | setValue (double q0, double q1, double q2, double q3) |
SbRotationd & | setValue (const SbMatrixd &m) |
SbRotationd & | setValue (const SbVec3d &axis, double radians) |
SbRotationd & | setValue (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) |
SbRotationd & | setValue (const SbRotation &rotate) |
SbRotationd & | setValue (const SbMatrix &m) |
SbRotationd & | setValue (const SbMatrix3 &m) |
SbRotationd & | operator*= (const SbRotationd &q) |
SbBool | equals (const SbRotationd &r, double tolerance) const |
void | multVec (const SbVec3d &src, SbVec3d &dst) const |
void | scaleAngle (double scaleFactor) |
Static Public Member Functions | |
static SbRotationd | slerp (const SbRotationd &rot0, const SbRotationd &rot1, double t) |
static SbRotationd | identity () |
Friends | |
int | operator== (const SbRotationd &q1, const SbRotationd &q2) |
int | operator!= (const SbRotationd &q1, const SbRotationd &q2) |
SbRotationd | operator* (const SbRotationd &q1, const SbRotationd &q2) |
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:
// Create a rotation of PI/2 radians around the Z axis: // Incorrect. // (Compiles, but actually sets the quaternion value directly!) SbRotationd rotation(0, 0, 1, 1.5707963); // This is the correct rotation. SbRotationd rotation( SbVec3d(0, 0, 1), 1.5707963);
SbRotation, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us
SbRotationd::SbRotationd | ( | ) | [inline] |
Constructor for rotation.
The initial value is no rotation.
SbRotationd::SbRotationd | ( | const double | v[4] | ) | [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).
SbRotationd::SbRotationd | ( | double | q0, | |
double | q1, | |||
double | q2, | |||
double | q3 | |||
) | [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).
SbRotationd::SbRotationd | ( | const SbMatrixd & | m | ) | [inline] |
Constructor.
The matrix constructor requires a valid rotation matrix.
SbRotationd::SbRotationd | ( | const SbMatrix3 & | m | ) | [inline] |
Constructor.
The matrix constructor requires a valid 3x3 rotation matrix.
SbRotationd::SbRotationd | ( | const SbVec3d & | axis, | |
double | radians | |||
) | [inline] |
Constructor.
The axis/radians constructor creates a rotation of angle radians about the given axis.
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.
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.
void SbRotationd::getValue | ( | SbMatrix3 & | matrix | ) | const |
Returns corresponding 3x3 rotation matrix.
void SbRotationd::getValue | ( | SbMatrix & | matrix | ) | const |
Returns corresponding 4x4 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.
void SbRotationd::getValue | ( | double & | q0, | |
double & | q1, | |||
double & | q2, | |||
double & | q3 | |||
) | const |
Returns 4 individual components of rotation quaternion.
const double* SbRotationd::getValue | ( | ) | const [inline] |
Returns pointer to array of 4 components defining quaternion.
static SbRotationd SbRotationd::identity | ( | ) | [inline, static] |
Returns a null rotation.
SbRotationd SbRotationd::inverse | ( | ) | const [inline] |
Returns the inverse of a rotation.
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 SbMatrix3 & | m | ) |
Sets rotation from a 3x3 rotation matrix.
SbRotationd& SbRotationd::setValue | ( | const SbMatrix & | m | ) |
Sets rotation from a single precision rotation matrix.
SbRotationd& SbRotationd::setValue | ( | const SbRotation & | rotate | ) |
Sets rotation from a single precision rotation.
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 | ( | const SbVec3d & | axis, | |
double | radians | |||
) |
Sets value of vector from 3D rotation axis vector and angle in radians.
SbRotationd& SbRotationd::setValue | ( | const SbMatrixd & | m | ) |
Sets value of rotation from a rotation matrix.
SbRotationd& SbRotationd::setValue | ( | double | q0, | |
double | q1, | |||
double | q2, | |||
double | q3 | |||
) |
Sets value of rotation from 4 individual components of a quaternion.
SbRotationd& SbRotationd::setValue | ( | const double | q[4] | ) |
Sets value of rotation from array of 4 components of a quaternion.
static SbRotationd SbRotationd::slerp | ( | const SbRotationd & | rot0, | |
const SbRotationd & | rot1, | |||
double | t | |||
) | [static] |
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
int operator!= | ( | const SbRotationd & | q1, | |
const SbRotationd & | q2 | |||
) | [friend] |
Inequality comparison operator.
SbRotationd operator* | ( | const SbRotationd & | q1, | |
const SbRotationd & | q2 | |||
) | [friend] |
Multiplication of two rotations; results in product of rotations.
int operator== | ( | const SbRotationd & | q1, | |
const SbRotationd & | q2 | |||
) | [friend] |
Equality comparison operator.