Class Rotation

java.lang.Object
com.j3d.engine.math.rot.Rotation

public class Rotation extends Object
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
    Modifier and Type
    Field
    Description
    private double
    Pitch: Rotation around the X-axis, in degrees.
    private double
    Roll: Rotation around the Z-axis, in degrees.
    private double
    Yaw: Rotation around the Y-axis, in degrees.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rotation(double pitch, double yaw, double roll)
    Constructs a new Rotation object with the specified angles.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a transformer for converting directions from **camera space to world space**.
    Creates a copy of this Rotation object.
    double
    Gets the pitch
    double
    Gets the roll
    double
    Gets the yaw
    void
    setPitch(double pitch)
    Sets the pitch
    void
    setRoll(double roll)
    Sets the roll
    void
    setYaw(double yaw)
    Sets the yaw
     
     
    Converts 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**.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pitch

      private double pitch
      Pitch: Rotation around the X-axis, in degrees.
    • yaw

      private double yaw
      Yaw: Rotation around the Y-axis, in degrees.
    • roll

      private double roll
      Roll: 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

      public WorldToCamDirection worldToCam()
      Creates a transformer for converting directions from **world space to camera space**.
      Returns:
      A new WorldToCamDirection instance configured with this rotation's angles.
    • camToWorld

      public CamToWorldDirection camToWorld()
      Creates a transformer for converting directions from **camera space to world space**.
      Returns:
      A new CamToWorldDirection instance 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

      public Vector3 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 Vector3 containing the pitch, yaw, and roll angles in radians.
    • copy

      public Rotation 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

      public String toLogString()
    • toMacroString

      public String toMacroString()