This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GfRotation Class Reference

Basic type: 3-space rotation specification. More...

#include <rotation.h>

Public Member Functions

 GfRotation ()
 The default constructor leaves the rotation undefined.
 
 GfRotation (const GfVec3d &axis, double angle)
 This constructor initializes the rotation to be angle degrees about axis.
 
 GfRotation (const GfQuaternion &quaternion)
 This constructor initializes the rotation from a quaternion.
 
 GfRotation (const GfQuatd &quat)
 This constructor initializes the rotation from a quaternion.
 
GF_API GfRotation (const GfVec3d &rotateFrom, const GfVec3d &rotateTo)
 This constructor initializes the rotation to one that brings the rotateFrom vector to align with rotateTo.
 
GfRotationSetAxisAngle (const GfVec3d &axis, double angle)
 Sets the rotation to be angle degrees about axis.
 
GF_API GfRotationSetQuat (const GfQuatd &quat)
 Sets the rotation from a quaternion.
 
GfRotationSetQuaternion (const GfQuaternion &quat)
 Sets the rotation from a quaternion.
 
GF_API GfRotationSetRotateInto (const GfVec3d &rotateFrom, const GfVec3d &rotateTo)
 Sets the rotation to one that brings the rotateFrom vector to align with rotateTo.
 
GfRotationSetIdentity ()
 Sets the rotation to an identity rotation.
 
const GfVec3dGetAxis () const
 Returns the axis of rotation.
 
double GetAngle () const
 Returns the rotation angle in degrees.
 
GfQuaternion GetQuaternion () const
 Returns the rotation expressed as a quaternion.
 
GF_API GfQuatd GetQuat () const
 Returns the rotation expressed as a quaternion.
 
GfRotation GetInverse () const
 Returns the inverse of this rotation.
 
GF_API GfVec3d Decompose (const GfVec3d &axis0, const GfVec3d &axis1, const GfVec3d &axis2) const
 Decompose rotation about 3 orthogonal axes.
 
GF_API GfVec3d TransformDir (const GfVec3d &vec) const
 Transforms row vector vec by the rotation, returning the result.
 
bool operator== (const GfRotation &r) const
 Component-wise rotation equality test.
 
bool operator!= (const GfRotation &r) const
 Component-wise rotation inequality test.
 
GF_API GfRotationoperator*= (const GfRotation &r)
 Post-multiplies rotation r into this rotation.
 
GfRotationoperator*= (double scale)
 Scales rotation angle by multiplying by scale.
 
GfRotationoperator/= (double scale)
 Scales rotation angle by dividing by scale.
 

Static Public Member Functions

static GF_API void DecomposeRotation (const GfMatrix4d &rot, const GfVec3d &TwAxis, const GfVec3d &FBAxis, const GfVec3d &LRAxis, double handedness, double *thetaTw, double *thetaFB, double *thetaLR, double *thetaSw=nullptr, bool useHint=false, const double *swShift=nullptr)
 
static GF_API GfRotation RotateOntoProjected (const GfVec3d &v1, const GfVec3d &v2, const GfVec3d &axis)
 
static GF_API void MatchClosestEulerRotation (double targetTw, double targetFB, double targetLR, double targetSw, double *thetaTw, double *thetaFB, double *thetaLR, double *thetaSw)
 Replace the hint angles with the closest rotation of the given rotation to the hint.
 

Friends

size_t hash_value (const GfRotation &r)
 Hash.
 
GfRotation operator* (const GfRotation &r1, const GfRotation &r2)
 Returns composite rotation of rotations r1 and r2.
 
GfRotation operator* (const GfRotation &r, double scale)
 Returns a rotation equivalent to r with its angle multiplied by scale.
 
GfRotation operator* (double scale, const GfRotation &r)
 Returns a rotation equivalent to r with its angle multiplied by scale.
 
GfRotation operator/ (const GfRotation &r, double scale)
 Returns a rotation equivalent to r with its angle divided by scale.
 

Detailed Description

Basic type: 3-space rotation specification.

This class represents a rotation in 3-space. This stores an axis as a normalized vector of 3 doubles and an angle in degrees (as a double). Rotations follow the right-hand rule: a positive rotation about an axis vector appears counter-clockwise when looking from the end of the vector toward the origin.

Definition at line 37 of file rotation.h.

Constructor & Destructor Documentation

◆ GfRotation() [1/5]

GfRotation ( )
inline

The default constructor leaves the rotation undefined.

Definition at line 42 of file rotation.h.

◆ GfRotation() [2/5]

GfRotation ( const GfVec3d axis,
double  angle 
)
inline

This constructor initializes the rotation to be angle degrees about axis.

Definition at line 47 of file rotation.h.

◆ GfRotation() [3/5]

GfRotation ( const GfQuaternion quaternion)
inline

This constructor initializes the rotation from a quaternion.

Definition at line 52 of file rotation.h.

◆ GfRotation() [4/5]

GfRotation ( const GfQuatd quat)
inline

This constructor initializes the rotation from a quaternion.

Note that this constructor accepts GfQuatf and GfQuath since they implicitly convert to GfQuatd.

Definition at line 59 of file rotation.h.

◆ GfRotation() [5/5]

GF_API GfRotation ( const GfVec3d rotateFrom,
const GfVec3d rotateTo 
)
inline

This constructor initializes the rotation to one that brings the rotateFrom vector to align with rotateTo.

The passed vectors need not be unit length.

Definition at line 65 of file rotation.h.

Member Function Documentation

◆ Decompose()

GF_API GfVec3d Decompose ( const GfVec3d axis0,
const GfVec3d axis1,
const GfVec3d axis2 
) const

Decompose rotation about 3 orthogonal axes.

If the axes are not orthogonal, warnings will be spewed.

◆ GetAngle()

double GetAngle ( ) const
inline

Returns the rotation angle in degrees.

Definition at line 109 of file rotation.h.

◆ GetAxis()

const GfVec3d & GetAxis ( ) const
inline

Returns the axis of rotation.

Definition at line 104 of file rotation.h.

◆ GetInverse()

GfRotation GetInverse ( ) const
inline

Returns the inverse of this rotation.

Definition at line 124 of file rotation.h.

◆ GetQuat()

GF_API GfQuatd GetQuat ( ) const

Returns the rotation expressed as a quaternion.

◆ GetQuaternion()

GfQuaternion GetQuaternion ( ) const
inline

Returns the rotation expressed as a quaternion.

Definition at line 114 of file rotation.h.

◆ MatchClosestEulerRotation()

static GF_API void MatchClosestEulerRotation ( double  targetTw,
double  targetFB,
double  targetLR,
double  targetSw,
double *  thetaTw,
double *  thetaFB,
double *  thetaLR,
double *  thetaSw 
)
static

Replace the hint angles with the closest rotation of the given rotation to the hint.

Each angle in the rotation will be within Pi of the corresponding hint angle and the sum of the differences with the hint will be minimized. If a given rotation value is null then that angle will be treated as 0.0 and ignored in the calculations.

All angles are in radians. The rotation order is Tw/FB/LR/Sw.

◆ operator!=()

bool operator!= ( const GfRotation r) const
inline

Component-wise rotation inequality test.

The axes and angles must match exactly for rotations to be considered equal. (To compare equality of the actual rotations, you can convert both to quaternions and test the results for equality.)

Definition at line 218 of file rotation.h.

◆ operator*=() [1/2]

GF_API GfRotation & operator*= ( const GfRotation r)

Post-multiplies rotation r into this rotation.

◆ operator*=() [2/2]

GfRotation & operator*= ( double  scale)
inline

Scales rotation angle by multiplying by scale.

Definition at line 227 of file rotation.h.

◆ operator/=()

GfRotation & operator/= ( double  scale)
inline

Scales rotation angle by dividing by scale.

Definition at line 233 of file rotation.h.

◆ operator==()

bool operator== ( const GfRotation r) const
inline

Component-wise rotation equality test.

The axes and angles must match exactly for rotations to be considered equal. (To compare equality of the actual rotations, you can convert both to quaternions and test the results for equality.)

Definition at line 209 of file rotation.h.

◆ SetAxisAngle()

GfRotation & SetAxisAngle ( const GfVec3d axis,
double  angle 
)
inline

Sets the rotation to be angle degrees about axis.

Definition at line 70 of file rotation.h.

◆ SetIdentity()

GfRotation & SetIdentity ( )
inline

Sets the rotation to an identity rotation.

(This is chosen to be 0 degrees around the positive X axis.)

Definition at line 97 of file rotation.h.

◆ SetQuat()

GF_API GfRotation & SetQuat ( const GfQuatd quat)

Sets the rotation from a quaternion.

Note that this method accepts GfQuatf and GfQuath since they implicitly convert to GfQuatd.

◆ SetQuaternion()

GfRotation & SetQuaternion ( const GfQuaternion quat)
inline

Sets the rotation from a quaternion.

Definition at line 84 of file rotation.h.

◆ SetRotateInto()

GF_API GfRotation & SetRotateInto ( const GfVec3d rotateFrom,
const GfVec3d rotateTo 
)

Sets the rotation to one that brings the rotateFrom vector to align with rotateTo.

The passed vectors need not be unit length.

◆ TransformDir()

GF_API GfVec3d TransformDir ( const GfVec3d vec) const

Transforms row vector vec by the rotation, returning the result.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( const GfRotation r)
friend

Hash.

Definition at line 201 of file rotation.h.

◆ operator* [1/3]

GfRotation operator* ( const GfRotation r,
double  scale 
)
friend

Returns a rotation equivalent to r with its angle multiplied by scale.

Definition at line 247 of file rotation.h.

◆ operator* [2/3]

GfRotation operator* ( const GfRotation r1,
const GfRotation r2 
)
friend

Returns composite rotation of rotations r1 and r2.

Definition at line 239 of file rotation.h.

◆ operator* [3/3]

GfRotation operator* ( double  scale,
const GfRotation r 
)
friend

Returns a rotation equivalent to r with its angle multiplied by scale.

Definition at line 254 of file rotation.h.

◆ operator/

GfRotation operator/ ( const GfRotation r,
double  scale 
)
friend

Returns a rotation equivalent to r with its angle divided by scale.

Definition at line 260 of file rotation.h.


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