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

Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation. More...

#include <RotationMatrix.h>

Collaboration diagram for RotationMatrix:

Public Member Functions

Vector3D ConvertCoordinateToVector ()
 Converts the current coordinate system to a vector representation.
 
void ReadjustMatrix ()
 Recalculates and adjusts the rotation matrix axes to maintain orthogonality.
 
Vector3D Rotate (Vector3D rotation)
 Rotates the matrix by a given rotation vector.
 
Vector3D RotateX (float theta)
 Rotates the matrix around the X-axis.
 
Vector3D RotateY (float theta)
 Rotates the matrix around the Y-axis.
 
Vector3D RotateZ (float theta)
 Rotates the matrix around the Z-axis.
 
void RotateRelative (RotationMatrix rM)
 Rotates this matrix relative to another rotation matrix.
 
 RotationMatrix ()
 Default constructor. Initializes the matrix to the identity matrix.
 
 RotationMatrix (Vector3D axes)
 Constructs a rotation matrix from a single vector.
 
 RotationMatrix (Vector3D X, Vector3D Y, Vector3D Z)
 Constructs a rotation matrix from three orthogonal vectors.
 
RotationMatrix Multiply (float d)
 Multiplies the rotation matrix by a scalar.
 
RotationMatrix Multiply (RotationMatrix rM)
 Multiplies the rotation matrix by another rotation matrix.
 
RotationMatrix Normalize ()
 Normalizes the rotation matrix to ensure orthogonality.
 
RotationMatrix Transpose ()
 Transposes the rotation matrix.
 
RotationMatrix Inverse ()
 Inverts the rotation matrix.
 
bool IsEqual (RotationMatrix rM)
 Checks if two rotation matrices are equal.
 
float Determinant ()
 Computes the determinant of the rotation matrix.
 
String ToString ()
 Converts the rotation matrix to a string representation.
 
RotationMatrix operator= (RotationMatrix rM)
 Assignment operator for rotation matrices.
 

Static Public Member Functions

static Vector3D RotateVector (Vector3D rotate, Vector3D coordinates)
 Rotates a vector using the rotation matrix.
 

Public Attributes

Vector3D XAxis
 X-axis vector of the rotation matrix.
 
Vector3D YAxis
 Y-axis vector of the rotation matrix.
 
Vector3D ZAxis
 Z-axis vector of the rotation matrix.
 

Private Attributes

Vector3D InitialVector
 Initial vector used for transformations.
 
bool didRotate
 Tracks whether the matrix has been rotated.
 

Detailed Description

Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation.

Definition at line 23 of file RotationMatrix.h.

Constructor & Destructor Documentation

◆ RotationMatrix() [1/3]

Default constructor. Initializes the matrix to the identity matrix.

Definition at line 86 of file RotationMatrix.cpp.

References XAxis, YAxis, and ZAxis.

Referenced by RotateVector().

◆ RotationMatrix() [2/3]

Constructs a rotation matrix from a single vector.

Parameters
axesA vector representing the axes for rotation.

Definition at line 92 of file RotationMatrix.cpp.

References XAxis, YAxis, and ZAxis.

◆ RotationMatrix() [3/3]

Constructs a rotation matrix from three orthogonal vectors.

Parameters
XX-axis vector.
YY-axis vector.
ZZ-axis vector.

Definition at line 98 of file RotationMatrix.cpp.

References XAxis, YAxis, and ZAxis.

Member Function Documentation

◆ ConvertCoordinateToVector()

Vector3D ConvertCoordinateToVector ( )

Converts the current coordinate system to a vector representation.

Returns
A vector representing the transformed coordinate.

Definition at line 3 of file RotationMatrix.cpp.

References didRotate, InitialVector, Vector3D::X, XAxis, Vector3D::Y, YAxis, Vector3D::Z, and ZAxis.

Referenced by Rotate(), RotateX(), RotateY(), and RotateZ().

◆ Determinant()

float Determinant ( )

Computes the determinant of the rotation matrix.

Returns
The determinant value.

Definition at line 156 of file RotationMatrix.cpp.

References Vector3D::X, XAxis, Vector3D::Y, YAxis, Vector3D::Z, and ZAxis.

Referenced by Inverse().

◆ Inverse()

RotationMatrix Inverse ( )

Inverts the rotation matrix.

Returns
The inverted rotation matrix.

Definition at line 139 of file RotationMatrix.cpp.

References Vector3D::CrossProduct(), Determinant(), Multiply(), Transpose(), XAxis, YAxis, and ZAxis.

◆ IsEqual()

bool IsEqual ( RotationMatrix  rM)

Checks if two rotation matrices are equal.

Parameters
rMThe rotation matrix to compare with.
Returns
True if the matrices are equal, false otherwise.

Definition at line 152 of file RotationMatrix.cpp.

References Vector3D::IsEqual(), XAxis, YAxis, and ZAxis.

◆ Multiply() [1/2]

RotationMatrix Multiply ( float  d)

Multiplies the rotation matrix by a scalar.

Parameters
dThe scalar value to multiply.
Returns
The resulting scaled rotation matrix.

Definition at line 104 of file RotationMatrix.cpp.

References Vector3D::Multiply(), XAxis, YAxis, and ZAxis.

Referenced by Inverse(), and RotateRelative().

◆ Multiply() [2/2]

RotationMatrix Multiply ( RotationMatrix  rM)

Multiplies the rotation matrix by another rotation matrix.

Parameters
rMThe rotation matrix to multiply by.
Returns
The resulting rotation matrix.

Definition at line 112 of file RotationMatrix.cpp.

References Vector3D::Multiply(), XAxis, YAxis, and ZAxis.

◆ Normalize()

RotationMatrix Normalize ( )

Normalizes the rotation matrix to ensure orthogonality.

Returns
The normalized rotation matrix.

Definition at line 120 of file RotationMatrix.cpp.

References Vector3D::CrossProduct(), Vector3D::UnitSphere(), XAxis, and YAxis.

◆ operator=()

Assignment operator for rotation matrices.

Parameters
rMThe rotation matrix to assign.
Returns
The resulting rotation matrix.

Definition at line 184 of file RotationMatrix.cpp.

References XAxis, YAxis, and ZAxis.

◆ ReadjustMatrix()

void ReadjustMatrix ( )

Recalculates and adjusts the rotation matrix axes to maintain orthogonality.

Definition at line 12 of file RotationMatrix.cpp.

References Vector3D::X, XAxis, Vector3D::Y, YAxis, Vector3D::Z, and ZAxis.

Referenced by Rotate().

◆ Rotate()

Vector3D Rotate ( Vector3D  rotation)

Rotates the matrix by a given rotation vector.

Parameters
rotationA vector representing the rotation in radians for each axis.
Returns
The resulting rotated vector.

Definition at line 22 of file RotationMatrix.cpp.

References ConvertCoordinateToVector(), didRotate, ReadjustMatrix(), RotateX(), RotateY(), RotateZ(), Vector3D::X, Vector3D::Y, and Vector3D::Z.

◆ RotateRelative()

void RotateRelative ( RotationMatrix  rM)

Rotates this matrix relative to another rotation matrix.

Parameters
rMThe rotation matrix to apply.

Definition at line 82 of file RotationMatrix.cpp.

References Multiply().

◆ RotateVector()

Vector3D RotateVector ( Vector3D  rotate,
Vector3D  coordinates 
)
static

Rotates a vector using the rotation matrix.

Parameters
rotateThe vector to rotate.
coordinatesThe rotation coordinates.
Returns
The rotated vector.

Definition at line 162 of file RotationMatrix.cpp.

References RotationMatrix().

Referenced by Rotation::DirectionAngleToQuaternion().

◆ RotateX()

Vector3D RotateX ( float  theta)

Rotates the matrix around the X-axis.

Parameters
thetaThe angle in radians to rotate.
Returns
The resulting rotated vector.

Definition at line 49 of file RotationMatrix.cpp.

References ConvertCoordinateToVector(), Mathematics::DegreesToRadians(), Vector3D::Multiply(), XAxis, YAxis, and ZAxis.

Referenced by Rotate().

◆ RotateY()

Vector3D RotateY ( float  theta)

Rotates the matrix around the Y-axis.

Parameters
thetaThe angle in radians to rotate.
Returns
The resulting rotated vector.

Definition at line 60 of file RotationMatrix.cpp.

References ConvertCoordinateToVector(), Mathematics::DegreesToRadians(), Vector3D::Multiply(), XAxis, YAxis, and ZAxis.

Referenced by Rotate().

◆ RotateZ()

Vector3D RotateZ ( float  theta)

Rotates the matrix around the Z-axis.

Parameters
thetaThe angle in radians to rotate.
Returns
The resulting rotated vector.

Definition at line 71 of file RotationMatrix.cpp.

References ConvertCoordinateToVector(), Mathematics::DegreesToRadians(), Vector3D::Multiply(), XAxis, YAxis, and ZAxis.

Referenced by Rotate().

◆ ToString()

String ToString ( )

Converts the rotation matrix to a string representation.

Returns
A string representing the matrix.

Definition at line 176 of file RotationMatrix.cpp.

References Vector3D::ToString(), XAxis, YAxis, and ZAxis.

◆ Transpose()

RotationMatrix Transpose ( )

Transposes the rotation matrix.

Returns
The transposed rotation matrix.

Definition at line 131 of file RotationMatrix.cpp.

References Vector3D::X, XAxis, Vector3D::Y, YAxis, Vector3D::Z, and ZAxis.

Referenced by Inverse().

Member Data Documentation

◆ didRotate

bool didRotate
private

Tracks whether the matrix has been rotated.

Definition at line 26 of file RotationMatrix.h.

Referenced by ConvertCoordinateToVector(), and Rotate().

◆ InitialVector

Vector3D InitialVector
private

Initial vector used for transformations.

Definition at line 25 of file RotationMatrix.h.

Referenced by ConvertCoordinateToVector().

◆ XAxis

◆ YAxis

◆ ZAxis


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