ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1/**
2 * @file Transform.h
3 * @brief Defines the Transform class for managing position, rotation, and scale of objects.
4 *
5 * The Transform class provides functionality to represent and manipulate an object's position,
6 * rotation, scale, and associated offsets in 3D space.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Rotation.h"
16#include "Vector3D.h"
17
18/**
19 * @class Transform
20 * @brief Represents a 3D transformation including position, rotation, and scale.
21 */
22class Transform {
23private:
24 Quaternion baseRotation; ///< The base rotation of the object as a quaternion.
25 Quaternion rotation; ///< The current rotation of the object as a quaternion.
26 Vector3D position; ///< The position of the object in 3D space.
27 Vector3D scale; ///< The scale of the object in 3D space.
28 Quaternion scaleRotationOffset; ///< Offset for scaling transformations relative to rotation.
29
30 Vector3D scaleOffset; ///< Offset applied to the scale.
31 Vector3D rotationOffset; ///< Offset applied to the rotation.
32
33public:
34 /**
35 * @brief Default constructor.
36 */
37 Transform();
38
39 /**
40 * @brief Constructor initializing with Euler angles, position, and scale.
41 * @param eulerXYZS The rotation in XYZ static Euler angles.
42 * @param position The position vector.
43 * @param scale The scale vector.
44 */
46
47 /**
48 * @brief Constructor initializing with rotation, position, and scale.
49 * @param rotation The rotation as a quaternion.
50 * @param position The position vector.
51 * @param scale The scale vector.
52 */
54
55 /**
56 * @brief Constructor initializing with additional rotation and scale offsets.
57 * @param eulerXYZS The rotation in XYZ static Euler angles.
58 * @param position The position vector.
59 * @param scale The scale vector.
60 * @param rotationOffset Offset for the rotation.
61 * @param scaleOffset Offset for the scale.
62 */
64
65 /**
66 * @brief Constructor initializing with rotation and offsets.
67 * @param rotation The rotation as a quaternion.
68 * @param position The position vector.
69 * @param scale The scale vector.
70 * @param rotationOffset Offset for the rotation.
71 * @param scaleOffset Offset for the scale.
72 */
74
75 /**
76 * @brief Copy constructor.
77 * @param transform The transform to copy.
78 */
79 Transform(const Transform& transform);
80
81 /**
82 * @brief Sets the base rotation of the object.
83 * @param baseRotation The base rotation as a quaternion.
84 */
86
87 /**
88 * @brief Gets the base rotation of the object.
89 * @return The base rotation as a quaternion.
90 */
92
93 /**
94 * @brief Sets the current rotation of the object.
95 * @param rotation The rotation as a quaternion.
96 */
97 void SetRotation(const Quaternion& rotation);
98
99 /**
100 * @brief Sets the current rotation of the object using Euler angles.
101 * @param eulerXYZS The rotation in XYZ static Euler angles.
102 */
103 void SetRotation(const Vector3D& eulerXYZS);
104
105 /**
106 * @brief Gets the current rotation of the object.
107 * @return The current rotation as a quaternion.
108 */
110
111 /**
112 * @brief Sets the position of the object.
113 * @param position The position vector.
114 */
115 void SetPosition(const Vector3D& position);
116
117 /**
118 * @brief Gets the position of the object.
119 * @return The position vector.
120 */
122
123 /**
124 * @brief Sets the scale of the object.
125 * @param scale The scale vector.
126 */
127 void SetScale(const Vector3D& scale);
128
129 /**
130 * @brief Gets the scale of the object.
131 * @return The scale vector.
132 */
134
135 /**
136 * @brief Sets the scale rotation offset of the object.
137 * @param scaleRotationOffset The scale rotation offset as a quaternion.
138 */
140
141 /**
142 * @brief Gets the scale rotation offset of the object.
143 * @return The scale rotation offset as a quaternion.
144 */
146
147 /**
148 * @brief Sets the rotation offset of the object.
149 * @param rotationOffset The rotation offset vector.
150 */
152
153 /**
154 * @brief Gets the rotation offset of the object.
155 * @return The rotation offset vector.
156 */
158
159 /**
160 * @brief Sets the scale offset of the object.
161 * @param scaleOffset The scale offset vector.
162 */
164
165 /**
166 * @brief Gets the scale offset of the object.
167 * @return The scale offset vector.
168 */
170
171 /**
172 * @brief Rotates the object by the given Euler angles.
173 * @param eulerXYZS The rotation in XYZ static Euler angles.
174 */
175 void Rotate(const Vector3D& eulerXYZS);
176
177 /**
178 * @brief Rotates the object by the given quaternion.
179 * @param rotation The rotation as a quaternion.
180 */
181 void Rotate(const Quaternion& rotation);
182
183 /**
184 * @brief Translates the object by the given offset.
185 * @param offset The translation offset vector.
186 */
187 void Translate(const Vector3D& offset);
188
189 /**
190 * @brief Scales the object by the given scale factors.
191 * @param scale The scale factors as a vector.
192 */
193 void Scale(const Vector3D& scale);
194
195 /**
196 * @brief Converts the transform to a string representation.
197 * @return A string representing the transform.
198 */
200};
Defines the Rotation class for handling 3D rotations using various representations.
Defines a 3D vector and various related operations.
Implements a generic Kalman Filter for 1D data.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
String ToString()
Converts the transform to a string representation.
void Translate(const Vector3D &offset)
Translates the object by the given offset.
Vector3D GetRotationOffset()
Gets the rotation offset of the object.
Definition Transform.cpp:93
Vector3D scale
The scale of the object in 3D space.
Definition Transform.h:27
void SetScale(const Vector3D &scale)
Sets the scale of the object.
Definition Transform.cpp:73
Quaternion scaleRotationOffset
Offset for scaling transformations relative to rotation.
Definition Transform.h:28
void Scale(const Vector3D &scale)
Scales the object by the given scale factors.
Quaternion rotation
The current rotation of the object as a quaternion.
Definition Transform.h:25
Quaternion GetRotation()
Gets the current rotation of the object.
Definition Transform.cpp:61
Vector3D scaleOffset
Offset applied to the scale.
Definition Transform.h:30
void SetBaseRotation(const Quaternion &baseRotation)
Sets the base rotation of the object.
Definition Transform.cpp:45
Vector3D rotationOffset
Offset applied to the rotation.
Definition Transform.h:31
Quaternion GetBaseRotation()
Gets the base rotation of the object.
Definition Transform.cpp:49
Quaternion GetScaleRotationOffset()
Gets the scale rotation offset of the object.
Definition Transform.cpp:85
Vector3D position
The position of the object in 3D space.
Definition Transform.h:26
void SetScaleOffset(const Vector3D &scaleOffset)
Sets the scale offset of the object.
Definition Transform.cpp:97
Transform()
Default constructor.
Definition Transform.cpp:4
Vector3D GetPosition()
Gets the position of the object.
Definition Transform.cpp:69
void Rotate(const Vector3D &eulerXYZS)
Rotates the object by the given Euler angles.
void SetPosition(const Vector3D &position)
Sets the position of the object.
Definition Transform.cpp:65
void SetScaleRotationOffset(const Quaternion &scaleRotationOffset)
Sets the scale rotation offset of the object.
Definition Transform.cpp:81
void SetRotationOffset(const Vector3D &rotationOffset)
Sets the rotation offset of the object.
Definition Transform.cpp:89
Vector3D GetScaleOffset()
Gets the scale offset of the object.
Vector3D GetScale()
Gets the scale of the object.
Definition Transform.cpp:77
void SetRotation(const Quaternion &rotation)
Sets the current rotation of the object.
Definition Transform.cpp:53
Quaternion baseRotation
The base rotation of the object as a quaternion.
Definition Transform.h:24
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26