Class Rotation2d

java.lang.Object
me.autobot.lib.math.rotation.Rotation2d

public class Rotation2d extends Object
A 2D rotation in radians.
  • Constructor Details

    • Rotation2d

      public Rotation2d()
      Create a new Rotation2d with an angle of 0.
    • Rotation2d

      public Rotation2d(double theta)
      Create a new Rotation2d with the given angle in radians.
      Parameters:
      theta - The angle in radians.
  • Method Details

    • getTheta

      public double getTheta()
      Returns the angle in radians.
      Returns:
      The angle in radians.
    • setTheta

      public void setTheta(double theta)
      Sets the angle in radians.
      Parameters:
      theta - The angle in radians.
    • rotateBy

      public Rotation2d rotateBy(Rotation2d other)
      Rotate the angle by the given angle.
      Parameters:
      other - The angle to rotate by.
      Returns:
      A new Rotation2d with the angle rotated by the given angle.
    • normal

      public Rotation2d normal()
      Returns the normal of the angle (adding 90 degrees).
      Returns:
      A new Rotation2d with the angle normal to the current angle.
    • inverse

      public Rotation2d inverse()
      Returns the inverse of the angle.
      Returns:
      A new Rotation2d with the angle inverted.
    • cos

      public double cos()
      Returns the cosine of the angle.
      Returns:
      The cosine of the angle.
    • sin

      public double sin()
      Returns the sine of the angle.
      Returns:
      The sine of the angle.
    • tan

      public double tan()
      Returns the tangent of the angle.
      Returns:
      The tangent of the angle.
    • getRadians

      public double getRadians()
      Returns the angle in radians.
      Returns:
      The angle in radians.
    • getDegrees

      public double getDegrees()
      Returns the angle in degrees.
      Returns:
      The angle in degrees.
    • toVector

      public Vector2d toVector()
      Converts the angle to a vector (unit vector).
      Returns:
      A new Vector2d equivalent to the angle / in the direction of the angle.
    • toVector3d

      public Vector3d toVector3d()
      Converts the angle to a 3D vector (unit vector).
      Returns:
      A new Vector3d equivalent to the angle / in the direction of the angle, but z=0.
    • fromDegrees

      public static Rotation2d fromDegrees(double degrees)
      Create a new Rotation2d with the given degrees.
      Parameters:
      degrees - The angle in degrees.
      Returns:
      A new Rotation2d with the given angle in degrees.
    • fromRadians

      public static Rotation2d fromRadians(double radians)
      Create a new Rotation2d with the given radians.
      Parameters:
      radians - The angle in radians.
      Returns:
      A new Rotation2d with the given angle in radians.
    • zero

      public static Rotation2d zero()
      Create a new Rotation2d with an angle of 0.
      Returns:
      A new Rotation2d with an angle of 0.
    • clone

      public Rotation2d clone()
      Clone the Rotation2d.
      Overrides:
      clone in class Object
      Returns:
      A new Rotation2d with the same angle as the current one.