ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Rotation Class Reference

Handles 3D rotations and conversions between various rotation representations. More...

#include <Rotation.h>

Collaboration diagram for Rotation:

Public Member Functions

 Rotation ()
 Default constructor.
 
 Rotation (const Quaternion &quaternion)
 Constructor from a Quaternion.
 
 Rotation (const AxisAngle &axisAngle)
 Constructor from an AxisAngle representation.
 
 Rotation (const DirectionAngle &directionAngle)
 Constructor from a DirectionAngle representation.
 
 Rotation (const RotationMatrix &rotationMatrix)
 Constructor from a RotationMatrix.
 
 Rotation (const Vector3D &X, const Vector3D &Y, const Vector3D &Z)
 Constructor from basis vectors.
 
 Rotation (const EulerAngles &eulerAngles)
 Constructor from Euler angles.
 
 Rotation (const Vector3D &initial, const Vector3D &target)
 Constructor from direction vectors.
 
 Rotation (const YawPitchRoll &ypr)
 Constructor from a YawPitchRoll representation.
 
Quaternion GetQuaternion ()
 Gets the quaternion representation of the rotation.
 
AxisAngle GetAxisAngle ()
 Gets the axis-angle representation of the rotation.
 
DirectionAngle GetDirectionAngle ()
 Gets the direction-angle representation of the rotation.
 
RotationMatrix GetRotationMatrix ()
 Gets the rotation matrix representation of the rotation.
 
EulerAngles GetEulerAngles (const EulerOrder &order)
 Gets the Euler angles representation of the rotation.
 
YawPitchRoll GetYawPitchRoll ()
 Gets the yaw-pitch-roll representation of the rotation.
 

Private Member Functions

Quaternion AxisAngleToQuaternion (const AxisAngle &axisAngle)
 Converts an AxisAngle to a Quaternion.
 
Quaternion DirectionAngleToQuaternion (const DirectionAngle &directionAngle)
 Converts a DirectionAngle to a Quaternion.
 
Quaternion RotationMatrixToQuaternion (const RotationMatrix &rM)
 Converts a RotationMatrix to a Quaternion.
 
Quaternion RotationMatrixToQuaternion (const Vector3D &X, const Vector3D &Y, const Vector3D &Z)
 Converts three basis vectors to a Quaternion.
 
Quaternion EulerAnglesToQuaternion (const EulerAngles &eulerAngles)
 Converts Euler angles to a Quaternion.
 
Quaternion YawPitchRollToQuaternion (const YawPitchRoll &ypr)
 Converts a YawPitchRoll representation to a Quaternion.
 
EulerAngles RotationMatrixToEulerAngles (const RotationMatrix &rM, const EulerOrder &order)
 Converts a RotationMatrix to Euler angles.
 
RotationMatrix EulerAnglesToRotationMatrix (const EulerAngles &eulerAngles)
 Converts Euler angles to a RotationMatrix.
 
Quaternion QuaternionFromDirectionVectors (const Vector3D &initial, const Vector3D &target)
 Creates a Quaternion from direction vectors.
 

Private Attributes

Quaternion quaternionRotation
 Quaternion representation of the rotation.
 

Detailed Description

Handles 3D rotations and conversions between various rotation representations.

The Rotation class simplifies the process of converting between multiple rotation representations, enabling flexible handling of 3D rotations in applications such as graphics and robotics.

Definition at line 32 of file Rotation.h.

Constructor & Destructor Documentation

◆ Rotation() [1/9]

Rotation ( )

Default constructor.

Initializes the rotation to the identity quaternion.

Definition at line 198 of file Rotation.cpp.

References quaternionRotation.

Referenced by QuaternionFromDirectionVectors().

◆ Rotation() [2/9]

Rotation ( const Quaternion quaternion)

Constructor from a Quaternion.

Parameters
quaternionThe quaternion representation of the rotation.

Definition at line 202 of file Rotation.cpp.

References quaternionRotation.

◆ Rotation() [3/9]

Rotation ( const AxisAngle axisAngle)

Constructor from an AxisAngle representation.

Parameters
axisAngleThe axis-angle representation of the rotation.

Definition at line 206 of file Rotation.cpp.

References AxisAngleToQuaternion(), and quaternionRotation.

◆ Rotation() [4/9]

Rotation ( const DirectionAngle directionAngle)

Constructor from a DirectionAngle representation.

Parameters
directionAngleThe direction-angle representation of the rotation.

Definition at line 210 of file Rotation.cpp.

References DirectionAngleToQuaternion(), and quaternionRotation.

◆ Rotation() [5/9]

Rotation ( const RotationMatrix rotationMatrix)

Constructor from a RotationMatrix.

Parameters
rotationMatrixThe rotation matrix representation of the rotation.

Definition at line 214 of file Rotation.cpp.

References quaternionRotation, and RotationMatrixToQuaternion().

◆ Rotation() [6/9]

Rotation ( const Vector3D X,
const Vector3D Y,
const Vector3D Z 
)

Constructor from basis vectors.

Parameters
XThe X-axis vector.
YThe Y-axis vector.
ZThe Z-axis vector.

Definition at line 218 of file Rotation.cpp.

References quaternionRotation, and RotationMatrixToQuaternion().

◆ Rotation() [7/9]

Rotation ( const EulerAngles eulerAngles)

Constructor from Euler angles.

Parameters
eulerAnglesThe Euler angles representation of the rotation.

Definition at line 222 of file Rotation.cpp.

References EulerAnglesToQuaternion(), and quaternionRotation.

◆ Rotation() [8/9]

Rotation ( const Vector3D initial,
const Vector3D target 
)

Constructor from direction vectors.

Parameters
initialThe initial direction vector.
targetThe target direction vector.

Definition at line 226 of file Rotation.cpp.

References QuaternionFromDirectionVectors(), and quaternionRotation.

◆ Rotation() [9/9]

Constructor from a YawPitchRoll representation.

Parameters
yprThe yaw-pitch-roll representation of the rotation.

Definition at line 230 of file Rotation.cpp.

References quaternionRotation, and YawPitchRollToQuaternion().

Member Function Documentation

◆ AxisAngleToQuaternion()

Quaternion AxisAngleToQuaternion ( const AxisAngle axisAngle)
private

Converts an AxisAngle to a Quaternion.

Parameters
axisAngleThe axis-angle representation.
Returns
The corresponding quaternion.

Definition at line 5 of file Rotation.cpp.

References Mathematics::DegreesToRadians().

Referenced by Rotation().

◆ DirectionAngleToQuaternion()

Quaternion DirectionAngleToQuaternion ( const DirectionAngle directionAngle)
private

Converts a DirectionAngle to a Quaternion.

Parameters
directionAngleThe direction-angle representation.
Returns
The corresponding quaternion.

Definition at line 17 of file Rotation.cpp.

References QuaternionFromDirectionVectors(), RotationMatrix::RotateVector(), RotationMatrixToQuaternion(), and Quaternion::UnitQuaternion().

Referenced by Rotation().

◆ EulerAnglesToQuaternion()

Quaternion EulerAnglesToQuaternion ( const EulerAngles eulerAngles)
private

Converts Euler angles to a Quaternion.

Parameters
eulerAnglesThe Euler angles representation.
Returns
The corresponding quaternion.

Definition at line 83 of file Rotation.cpp.

References Mathematics::DegreesToRadians(), EulerOrder::Rotating, EulerOrder::XYZ, EulerOrder::XZY, EulerOrder::YXZ, EulerOrder::YZX, EulerOrder::ZXY, and EulerOrder::ZYX.

Referenced by Rotation().

◆ EulerAnglesToRotationMatrix()

RotationMatrix EulerAnglesToRotationMatrix ( const EulerAngles eulerAngles)
private

Converts Euler angles to a RotationMatrix.

Parameters
eulerAnglesThe Euler angles representation.
Returns
The corresponding rotation matrix.

Definition at line 148 of file Rotation.cpp.

◆ GetAxisAngle()

AxisAngle GetAxisAngle ( )

Gets the axis-angle representation of the rotation.

Returns
The axis-angle representation.

Definition at line 238 of file Rotation.cpp.

References quaternionRotation, and Mathematics::RadiansToDegrees().

◆ GetDirectionAngle()

DirectionAngle GetDirectionAngle ( )

Gets the direction-angle representation of the rotation.

Returns
The direction-angle representation.

Definition at line 266 of file Rotation.cpp.

References QuaternionFromDirectionVectors(), quaternionRotation, Mathematics::RadiansToDegrees(), Quaternion::UnitQuaternion(), Vector3D::X, and Vector3D::Z.

◆ GetEulerAngles()

EulerAngles GetEulerAngles ( const EulerOrder order)

Gets the Euler angles representation of the rotation.

Parameters
orderThe Euler order to use for conversion.
Returns
The Euler angles representation.

Definition at line 300 of file Rotation.cpp.

References quaternionRotation, Mathematics::RadiansToDegrees(), EulerOrder::Rotating, EulerOrder::XYZ, EulerOrder::XZY, EulerOrder::YXZ, EulerOrder::YZX, EulerOrder::ZXY, and EulerOrder::ZYX.

Referenced by Transform::ToString().

◆ GetQuaternion()

◆ GetRotationMatrix()

RotationMatrix GetRotationMatrix ( )

Gets the rotation matrix representation of the rotation.

Returns
The rotation matrix representation.

Definition at line 288 of file Rotation.cpp.

References quaternionRotation, and Quaternion::RotateVector().

◆ GetYawPitchRoll()

YawPitchRoll GetYawPitchRoll ( )

Gets the yaw-pitch-roll representation of the rotation.

Returns
The yaw-pitch-roll representation.

Definition at line 397 of file Rotation.cpp.

References quaternionRotation, and Mathematics::RadiansToDegrees().

◆ QuaternionFromDirectionVectors()

Quaternion QuaternionFromDirectionVectors ( const Vector3D initial,
const Vector3D target 
)
private

Creates a Quaternion from direction vectors.

Parameters
initialThe initial direction vector.
targetThe target direction vector.
Returns
The corresponding quaternion.

Definition at line 154 of file Rotation.cpp.

References Vector3D::CrossProduct(), Vector3D::DotProduct(), Mathematics::MPI, and Rotation().

Referenced by DirectionAngleToQuaternion(), GetDirectionAngle(), and Rotation().

◆ RotationMatrixToEulerAngles()

EulerAngles RotationMatrixToEulerAngles ( const RotationMatrix rM,
const EulerOrder order 
)
private

Converts a RotationMatrix to Euler angles.

Parameters
rMThe rotation matrix representation.
orderThe Euler order to use for conversion.
Returns
The corresponding Euler angles.

Definition at line 142 of file Rotation.cpp.

◆ RotationMatrixToQuaternion() [1/2]

Quaternion RotationMatrixToQuaternion ( const RotationMatrix rM)
private

Converts a RotationMatrix to a Quaternion.

Parameters
rMThe rotation matrix representation.
Returns
The corresponding quaternion.

Definition at line 37 of file Rotation.cpp.

References RotationMatrixToQuaternion().

Referenced by DirectionAngleToQuaternion(), Rotation(), Rotation(), and RotationMatrixToQuaternion().

◆ RotationMatrixToQuaternion() [2/2]

Quaternion RotationMatrixToQuaternion ( const Vector3D X,
const Vector3D Y,
const Vector3D Z 
)
private

Converts three basis vectors to a Quaternion.

Parameters
XThe X-axis vector.
YThe Y-axis vector.
ZThe Z-axis vector.
Returns
The corresponding quaternion.

Definition at line 41 of file Rotation.cpp.

References Vector3D::X, Vector3D::Y, and Vector3D::Z.

◆ YawPitchRollToQuaternion()

Quaternion YawPitchRollToQuaternion ( const YawPitchRoll ypr)
private

Converts a YawPitchRoll representation to a Quaternion.

Parameters
yprThe yaw-pitch-roll representation.
Returns
The corresponding quaternion.

Definition at line 136 of file Rotation.cpp.

Referenced by Rotation().

Member Data Documentation

◆ quaternionRotation


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