ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Rotation.h
Go to the documentation of this file.
1/**
2 * @file Rotation.h
3 * @brief Defines the Rotation class for handling 3D rotations using various representations.
4 *
5 * The Rotation class provides conversions between different rotation representations,
6 * including quaternions, axis-angle, direction-angle, rotation matrices, Euler angles,
7 * and yaw-pitch-roll.
8 *
9 * @date 22/12/2024
10 * @version 1.0
11 * @author Coela Can't
12 */
13
14#pragma once
15
16#include "AxisAngle.h"
17#include "DirectionAngle.h"
18#include "EulerAngles.h"
19#include "EulerConstants.h"
20#include "Quaternion.h"
21#include "RotationMatrix.h"
22#include "Vector3D.h"
23#include "YawPitchRoll.h"
24
25/**
26 * @class Rotation
27 * @brief Handles 3D rotations and conversions between various rotation representations.
28 *
29 * The `Rotation` class simplifies the process of converting between multiple rotation representations,
30 * enabling flexible handling of 3D rotations in applications such as graphics and robotics.
31 */
32class Rotation {
33private:
34 Quaternion quaternionRotation; ///< Quaternion representation of the rotation.
35
36 /**
37 * @brief Converts an AxisAngle to a Quaternion.
38 *
39 * @param axisAngle The axis-angle representation.
40 * @return The corresponding quaternion.
41 */
43
44 /**
45 * @brief Converts a DirectionAngle to a Quaternion.
46 *
47 * @param directionAngle The direction-angle representation.
48 * @return The corresponding quaternion.
49 */
51
52 /**
53 * @brief Converts a RotationMatrix to a Quaternion.
54 *
55 * @param rM The rotation matrix representation.
56 * @return The corresponding quaternion.
57 */
59
60 /**
61 * @brief Converts three basis vectors to a Quaternion.
62 *
63 * @param X The X-axis vector.
64 * @param Y The Y-axis vector.
65 * @param Z The Z-axis vector.
66 * @return The corresponding quaternion.
67 */
69
70 /**
71 * @brief Converts Euler angles to a Quaternion.
72 *
73 * @param eulerAngles The Euler angles representation.
74 * @return The corresponding quaternion.
75 */
77
78 /**
79 * @brief Converts a YawPitchRoll representation to a Quaternion.
80 *
81 * @param ypr The yaw-pitch-roll representation.
82 * @return The corresponding quaternion.
83 */
85
86 /**
87 * @brief Converts a RotationMatrix to Euler angles.
88 *
89 * @param rM The rotation matrix representation.
90 * @param order The Euler order to use for conversion.
91 * @return The corresponding Euler angles.
92 */
94
95 /**
96 * @brief Converts Euler angles to a RotationMatrix.
97 *
98 * @param eulerAngles The Euler angles representation.
99 * @return The corresponding rotation matrix.
100 */
102
103 /**
104 * @brief Creates a Quaternion from direction vectors.
105 *
106 * @param initial The initial direction vector.
107 * @param target The target direction vector.
108 * @return The corresponding quaternion.
109 */
111
112public:
113 /**
114 * @brief Default constructor.
115 *
116 * Initializes the rotation to the identity quaternion.
117 */
118 Rotation();
119
120 /**
121 * @brief Constructor from a Quaternion.
122 *
123 * @param quaternion The quaternion representation of the rotation.
124 */
126
127 /**
128 * @brief Constructor from an AxisAngle representation.
129 *
130 * @param axisAngle The axis-angle representation of the rotation.
131 */
133
134 /**
135 * @brief Constructor from a DirectionAngle representation.
136 *
137 * @param directionAngle The direction-angle representation of the rotation.
138 */
140
141 /**
142 * @brief Constructor from a RotationMatrix.
143 *
144 * @param rotationMatrix The rotation matrix representation of the rotation.
145 */
147
148 /**
149 * @brief Constructor from basis vectors.
150 *
151 * @param X The X-axis vector.
152 * @param Y The Y-axis vector.
153 * @param Z The Z-axis vector.
154 */
155 Rotation(const Vector3D& X, const Vector3D& Y, const Vector3D& Z);
156
157 /**
158 * @brief Constructor from Euler angles.
159 *
160 * @param eulerAngles The Euler angles representation of the rotation.
161 */
163
164 /**
165 * @brief Constructor from direction vectors.
166 *
167 * @param initial The initial direction vector.
168 * @param target The target direction vector.
169 */
170 Rotation(const Vector3D& initial, const Vector3D& target);
171
172 /**
173 * @brief Constructor from a YawPitchRoll representation.
174 *
175 * @param ypr The yaw-pitch-roll representation of the rotation.
176 */
177 Rotation(const YawPitchRoll& ypr);
178
179 /**
180 * @brief Gets the quaternion representation of the rotation.
181 *
182 * @return The quaternion representing the rotation.
183 */
185
186 /**
187 * @brief Gets the axis-angle representation of the rotation.
188 *
189 * @return The axis-angle representation.
190 */
192
193 /**
194 * @brief Gets the direction-angle representation of the rotation.
195 *
196 * @return The direction-angle representation.
197 */
199
200 /**
201 * @brief Gets the rotation matrix representation of the rotation.
202 *
203 * @return The rotation matrix representation.
204 */
206
207 /**
208 * @brief Gets the Euler angles representation of the rotation.
209 *
210 * @param order The Euler order to use for conversion.
211 * @return The Euler angles representation.
212 */
214
215 /**
216 * @brief Gets the yaw-pitch-roll representation of the rotation.
217 *
218 * @return The yaw-pitch-roll representation.
219 */
221};
Represents a rotation defined by an axis and an angle.
Represents a rotation defined by a direction vector and an angle.
Represents rotations in 3D space using Euler angles.
Provides predefined constants for common Euler rotation orders.
Defines the Quaternion class for 3D rotations and transformations.
Defines the RotationMatrix class for representing and manipulating 3D rotation matrices.
Defines a 3D vector and various related operations.
Represents an orientation using yaw, pitch, and roll angles.
Defines a rotation in 3D space using an axis and an angle.
Definition AxisAngle.h:23
Defines a rotation in 3D space using a direction vector and a rotation angle.
Encapsulates a 3D rotation using Euler angles and a specific order of application.
Definition EulerAngles.h:25
Specifies the order and frame of reference for Euler rotations.
Definition EulerOrder.h:25
Implements a generic Kalman Filter for 1D data.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation.
Handles 3D rotations and conversions between various rotation representations.
Definition Rotation.h:32
EulerAngles RotationMatrixToEulerAngles(const RotationMatrix &rM, const EulerOrder &order)
Converts a RotationMatrix to Euler angles.
Definition Rotation.cpp:142
YawPitchRoll GetYawPitchRoll()
Gets the yaw-pitch-roll representation of the rotation.
Definition Rotation.cpp:397
RotationMatrix EulerAnglesToRotationMatrix(const EulerAngles &eulerAngles)
Converts Euler angles to a RotationMatrix.
Definition Rotation.cpp:148
Quaternion EulerAnglesToQuaternion(const EulerAngles &eulerAngles)
Converts Euler angles to a Quaternion.
Definition Rotation.cpp:83
Quaternion YawPitchRollToQuaternion(const YawPitchRoll &ypr)
Converts a YawPitchRoll representation to a Quaternion.
Definition Rotation.cpp:136
AxisAngle GetAxisAngle()
Gets the axis-angle representation of the rotation.
Definition Rotation.cpp:238
RotationMatrix GetRotationMatrix()
Gets the rotation matrix representation of the rotation.
Definition Rotation.cpp:288
EulerAngles GetEulerAngles(const EulerOrder &order)
Gets the Euler angles representation of the rotation.
Definition Rotation.cpp:300
Rotation()
Default constructor.
Definition Rotation.cpp:198
Quaternion GetQuaternion()
Gets the quaternion representation of the rotation.
Definition Rotation.cpp:234
DirectionAngle GetDirectionAngle()
Gets the direction-angle representation of the rotation.
Definition Rotation.cpp:266
Quaternion RotationMatrixToQuaternion(const RotationMatrix &rM)
Converts a RotationMatrix to a Quaternion.
Definition Rotation.cpp:37
Quaternion quaternionRotation
Quaternion representation of the rotation.
Definition Rotation.h:34
Quaternion DirectionAngleToQuaternion(const DirectionAngle &directionAngle)
Converts a DirectionAngle to a Quaternion.
Definition Rotation.cpp:17
Quaternion AxisAngleToQuaternion(const AxisAngle &axisAngle)
Converts an AxisAngle to a Quaternion.
Definition Rotation.cpp:5
Quaternion QuaternionFromDirectionVectors(const Vector3D &initial, const Vector3D &target)
Creates a Quaternion from direction vectors.
Definition Rotation.cpp:154
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
A class to represent yaw, pitch, and roll angles for orientation.