Open Inventor Release 2023.2.2
 
Loading...
Searching...
No Matches
SbRotationd Class Reference

VSG extension 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.
 
SbRotationdinvert ()
 Changes a rotation to be its inverse.
 
SbRotationd inverse () const
 Returns the inverse of a rotation.
 
SbRotationdsetValue (const double q[4])
 Sets value of rotation from array of 4 components of a quaternion.
 
SbRotationdsetValue (double q0, double q1, double q2, double q3)
 Sets value of rotation from 4 individual components of a quaternion.
 
SbRotationdsetValue (const SbMatrixd &m)
 Sets value of rotation from a rotation matrix.
 
SbRotationdsetValue (const SbVec3d &axis, double radians)
 Sets value of vector from 3D rotation axis vector and angle in radians.
 
SbRotationdsetValue (const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
 Sets rotation to rotate one direction vector to another.
 
SbRotationdsetValue (const SbRotation &rotate)
 Sets rotation from a single precision rotation.
 
SbRotationdsetValue (const SbMatrix &m)
 Sets rotation from a single precision rotation matrix.
 
SbRotationdsetValue (const SbMatrix3 &m)
 Sets rotation from a 3x3 rotation matrix.
 
SbRotationdoperator*= (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.
 

Detailed Description

VSG extension 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:

// 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);
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Class for repres...
Definition SbRotation.h:425
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214

SEE ALSO

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.

Constructor & Destructor Documentation

◆ SbRotationd() [1/7]

SbRotationd::SbRotationd ( )
inline

Constructor for rotation.

The initial value is no rotation.

Definition at line 431 of file SbRotation.h.

◆ SbRotationd() [2/7]

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).

Definition at line 439 of file SbRotation.h.

◆ SbRotationd() [3/7]

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).

Definition at line 447 of file SbRotation.h.

◆ SbRotationd() [4/7]

SbRotationd::SbRotationd ( const SbMatrixd m)
inline

Constructor.

The matrix constructor requires a valid rotation matrix.

Definition at line 454 of file SbRotation.h.

◆ SbRotationd() [5/7]

SbRotationd::SbRotationd ( const SbMatrix3 m)
inline

Constructor.

The matrix constructor requires a valid 3x3 rotation matrix.

Definition at line 461 of file SbRotation.h.

◆ SbRotationd() [6/7]

SbRotationd::SbRotationd ( const SbVec3d axis,
double  radians 
)
inline

Constructor.

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

Definition at line 468 of file SbRotation.h.

◆ SbRotationd() [7/7]

SbRotationd::SbRotationd ( const SbVec3d rotateFrom,
const SbVec3d rotateTo 
)
inline

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.

Member Function Documentation

◆ equals()

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.

◆ getValue() [1/6]

const double * SbRotationd::getValue ( ) const
inline

Returns pointer to array of 4 components defining quaternion.

Definition at line 483 of file SbRotation.h.

◆ getValue() [2/6]

void SbRotationd::getValue ( double &  q0,
double &  q1,
double &  q2,
double &  q3 
) const

Returns 4 individual components of rotation quaternion.

◆ getValue() [3/6]

void SbRotationd::getValue ( SbMatrix matrix) const

Returns corresponding 4x4 rotation matrix.

◆ getValue() [4/6]

void SbRotationd::getValue ( SbMatrix3 matrix) const

Returns corresponding 3x3 rotation matrix.

◆ getValue() [5/6]

void SbRotationd::getValue ( SbMatrixd matrix) const

Returns corresponding 4x4 rotation matrix.

◆ getValue() [6/6]

void SbRotationd::getValue ( SbVec3d axis,
double &  radians 
) const

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

◆ identity()

static SbRotationd SbRotationd::identity ( )
inlinestatic

Returns a null rotation.

Definition at line 617 of file SbRotation.h.

◆ inverse()

SbRotationd SbRotationd::inverse ( ) const
inline

Returns the inverse of a rotation.

Definition at line 525 of file SbRotation.h.

◆ invert()

SbRotationd & SbRotationd::invert ( )

Changes a rotation to be its inverse.

◆ multVec()

void SbRotationd::multVec ( const SbVec3d src,
SbVec3d dst 
) const

Multiplies the given vector by the matrix of this rotation.

◆ operator*=()

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

Multiplies by another rotation; results in product of rotations.

◆ scaleAngle()

void SbRotationd::scaleAngle ( double  scaleFactor)

Keep the axis the same.

Multiply the angle of rotation by the amount scaleFactor.

◆ setValue() [1/8]

SbRotationd & SbRotationd::setValue ( const double  q[4])

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

◆ setValue() [2/8]

SbRotationd & SbRotationd::setValue ( const SbMatrix m)

Sets rotation from a single precision rotation matrix.

◆ setValue() [3/8]

SbRotationd & SbRotationd::setValue ( const SbMatrix3 m)

Sets rotation from a 3x3 rotation matrix.

◆ setValue() [4/8]

SbRotationd & SbRotationd::setValue ( const SbMatrixd m)

Sets value of rotation from a rotation matrix.

◆ setValue() [5/8]

SbRotationd & SbRotationd::setValue ( const SbRotation rotate)

Sets rotation from a single precision rotation.

◆ setValue() [6/8]

SbRotationd & SbRotationd::setValue ( const SbVec3d axis,
double  radians 
)

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

◆ setValue() [7/8]

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.

◆ setValue() [8/8]

SbRotationd & SbRotationd::setValue ( double  q0,
double  q1,
double  q2,
double  q3 
)

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

◆ slerp()

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.

Friends And Related Symbol Documentation

◆ operator!=

int operator!= ( const SbRotationd q1,
const SbRotationd q2 
)
friend

Inequality comparison operator.

Definition at line 582 of file SbRotation.h.

◆ operator*

SbRotationd operator* ( const SbRotationd q1,
const SbRotationd q2 
)
friend

Multiplication of two rotations; results in product of rotations.

◆ operator==

int operator== ( const SbRotationd q1,
const SbRotationd q2 
)
friend

Equality comparison operator.


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