Package com.j3d.engine.math.rot
Class Rotation
java.lang.Object
com.j3d.engine.math.rot.Rotation
Represents an object's orientation in 3D space using Tait-Bryan angles (yaw, pitch, and roll).
This class stores angles in degrees and provides methods to generate transformation matrices
for converting vectors between world space and a local (camera) space. It acts as a factory
for CamToWorldDirection and WorldToCamDirection transformers.
The primary matrix generated via RotationMatrixDirection.matrix() is the view matrix, which transforms
coordinates from the world space into the camera's local space.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRotation(double pitch, double yaw, double roll) Constructs a new Rotation object with the specified angles. -
Method Summary
Modifier and TypeMethodDescriptionCreates a transformer for converting directions from **camera space to world space**.copy()Creates a copy of this Rotation object.doublegetPitch()Gets the pitchdoublegetRoll()Gets the rolldoublegetYaw()Gets the yawvoidsetPitch(double pitch) Sets the pitchvoidsetRoll(double roll) Sets the rollvoidsetYaw(double yaw) Sets the yawConverts the rotation angles from degrees to radians and returns them as a Vector3.Creates a transformer for converting directions from **world space to camera space**.
-
Field Details
-
pitch
private double pitchPitch: Rotation around the X-axis, in degrees. -
yaw
private double yawYaw: Rotation around the Y-axis, in degrees. -
roll
private double rollRoll: Rotation around the Z-axis, in degrees.
-
-
Constructor Details
-
Rotation
public Rotation(double pitch, double yaw, double roll) Constructs a new Rotation object with the specified angles.- Parameters:
pitch- The pitch angle in degrees (rotation around the X-axis).yaw- The yaw angle in degrees (rotation around the Y-axis).roll- The roll angle in degrees (rotation around the Z-axis).
-
-
Method Details
-
worldToCam
Creates a transformer for converting directions from **world space to camera space**.- Returns:
- A new
WorldToCamDirectioninstance configured with this rotation's angles.
-
camToWorld
Creates a transformer for converting directions from **camera space to world space**.- Returns:
- A new
CamToWorldDirectioninstance configured with this rotation's angles.
-
getYaw
public double getYaw()Gets the yaw- Returns:
- The yaw angle in degrees.
-
getPitch
public double getPitch()Gets the pitch- Returns:
- The pitch angle in degrees.
-
getRoll
public double getRoll()Gets the roll- Returns:
- The roll angle in degrees.
-
setPitch
public void setPitch(double pitch) Sets the pitch- Parameters:
pitch- The new pitch angle in degrees.
-
setYaw
public void setYaw(double yaw) Sets the yaw- Parameters:
yaw- The new yaw angle in degrees.
-
setRoll
public void setRoll(double roll) Sets the roll- Parameters:
roll- The new roll angle in degrees.
-
toRadVector3
Converts the rotation angles from degrees to radians and returns them as a Vector3. The components of the vector are (pitch, yaw, roll).- Returns:
- A
Vector3containing the pitch, yaw, and roll angles in radians.
-
copy
Creates a copy of this Rotation object.- Returns:
- A new Rotation object with the same pitch, yaw, and roll angles as this one.
-
toLogString
-
toMacroString
-