ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
RotationMatrix.h
Go to the documentation of this file.
1/**
2 * @file RotationMatrix.h
3 * @brief Defines the RotationMatrix class for representing and manipulating 3D rotation matrices.
4 *
5 * The RotationMatrix class provides methods for rotating vectors, constructing rotation matrices,
6 * and performing various matrix operations such as multiplication, normalization, transposition,
7 * and inversion.
8 *
9 * @date 22/12/2024
10 * @version 1.0
11 * @author Coela Can't
12 */
13
14#pragma once
15
16#include "Mathematics.h"
17#include "Vector3D.h"
18
19/**
20 * @class RotationMatrix
21 * @brief Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation.
22 */
24private:
25 Vector3D InitialVector; ///< Initial vector used for transformations.
26 bool didRotate; ///< Tracks whether the matrix has been rotated.
27
28public:
29 Vector3D XAxis; ///< X-axis vector of the rotation matrix.
30 Vector3D YAxis; ///< Y-axis vector of the rotation matrix.
31 Vector3D ZAxis; ///< Z-axis vector of the rotation matrix.
32
33 /**
34 * @brief Converts the current coordinate system to a vector representation.
35 * @return A vector representing the transformed coordinate.
36 */
38
39 /**
40 * @brief Recalculates and adjusts the rotation matrix axes to maintain orthogonality.
41 */
42 void ReadjustMatrix();
43
44 /**
45 * @brief Rotates the matrix by a given rotation vector.
46 * @param rotation A vector representing the rotation in radians for each axis.
47 * @return The resulting rotated vector.
48 */
49 Vector3D Rotate(Vector3D rotation);
50
51 /**
52 * @brief Rotates the matrix around the X-axis.
53 * @param theta The angle in radians to rotate.
54 * @return The resulting rotated vector.
55 */
56 Vector3D RotateX(float theta);
57
58 /**
59 * @brief Rotates the matrix around the Y-axis.
60 * @param theta The angle in radians to rotate.
61 * @return The resulting rotated vector.
62 */
63 Vector3D RotateY(float theta);
64
65 /**
66 * @brief Rotates the matrix around the Z-axis.
67 * @param theta The angle in radians to rotate.
68 * @return The resulting rotated vector.
69 */
70 Vector3D RotateZ(float theta);
71
72 /**
73 * @brief Rotates this matrix relative to another rotation matrix.
74 * @param rM The rotation matrix to apply.
75 */
77
78 /**
79 * @brief Default constructor.
80 * Initializes the matrix to the identity matrix.
81 */
83
84 /**
85 * @brief Constructs a rotation matrix from a single vector.
86 * @param axes A vector representing the axes for rotation.
87 */
89
90 /**
91 * @brief Constructs a rotation matrix from three orthogonal vectors.
92 * @param X X-axis vector.
93 * @param Y Y-axis vector.
94 * @param Z Z-axis vector.
95 */
97
98 /**
99 * @brief Multiplies the rotation matrix by a scalar.
100 * @param d The scalar value to multiply.
101 * @return The resulting scaled rotation matrix.
102 */
103 RotationMatrix Multiply(float d);
104
105 /**
106 * @brief Multiplies the rotation matrix by another rotation matrix.
107 * @param rM The rotation matrix to multiply by.
108 * @return The resulting rotation matrix.
109 */
111
112 /**
113 * @brief Normalizes the rotation matrix to ensure orthogonality.
114 * @return The normalized rotation matrix.
115 */
117
118 /**
119 * @brief Transposes the rotation matrix.
120 * @return The transposed rotation matrix.
121 */
123
124 /**
125 * @brief Inverts the rotation matrix.
126 * @return The inverted rotation matrix.
127 */
129
130 /**
131 * @brief Checks if two rotation matrices are equal.
132 * @param rM The rotation matrix to compare with.
133 * @return True if the matrices are equal, false otherwise.
134 */
136
137 /**
138 * @brief Computes the determinant of the rotation matrix.
139 * @return The determinant value.
140 */
141 float Determinant();
142
143 /**
144 * @brief Rotates a vector using the rotation matrix.
145 * @param rotate The vector to rotate.
146 * @param coordinates The rotation coordinates.
147 * @return The rotated vector.
148 */
149 static Vector3D RotateVector(Vector3D rotate, Vector3D coordinates);
150
151 /**
152 * @brief Converts the rotation matrix to a string representation.
153 * @return A string representing the matrix.
154 */
156
157 /**
158 * @brief Assignment operator for rotation matrices.
159 * @param rM The rotation matrix to assign.
160 * @return The resulting rotation matrix.
161 */
163};
Provides a collection of mathematical utility functions and constants.
Defines a 3D vector and various related operations.
Implements a generic Kalman Filter for 1D data.
Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation.
String ToString()
Converts the rotation matrix to a string representation.
RotationMatrix()
Default constructor. Initializes the matrix to the identity matrix.
Vector3D RotateZ(float theta)
Rotates the matrix around the Z-axis.
Vector3D YAxis
Y-axis vector of the rotation matrix.
bool IsEqual(RotationMatrix rM)
Checks if two rotation matrices are equal.
Vector3D InitialVector
Initial vector used for transformations.
RotationMatrix operator=(RotationMatrix rM)
Assignment operator for rotation matrices.
Vector3D Rotate(Vector3D rotation)
Rotates the matrix by a given rotation vector.
void ReadjustMatrix()
Recalculates and adjusts the rotation matrix axes to maintain orthogonality.
RotationMatrix Multiply(float d)
Multiplies the rotation matrix by a scalar.
float Determinant()
Computes the determinant of the rotation matrix.
Vector3D RotateY(float theta)
Rotates the matrix around the Y-axis.
Vector3D ConvertCoordinateToVector()
Converts the current coordinate system to a vector representation.
RotationMatrix Normalize()
Normalizes the rotation matrix to ensure orthogonality.
RotationMatrix Transpose()
Transposes the rotation matrix.
RotationMatrix Inverse()
Inverts the rotation matrix.
bool didRotate
Tracks whether the matrix has been rotated.
Vector3D XAxis
X-axis vector of the rotation matrix.
Vector3D ZAxis
Z-axis vector of the rotation matrix.
void RotateRelative(RotationMatrix rM)
Rotates this matrix relative to another rotation matrix.
static Vector3D RotateVector(Vector3D rotate, Vector3D coordinates)
Rotates a vector using the rotation matrix.
Vector3D RotateX(float theta)
Rotates the matrix around the X-axis.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26