Package me.autobot.lib.math.rotation
Class Rotation2d
java.lang.Object
me.autobot.lib.math.rotation.Rotation2d
A 2D rotation in radians.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Rotation2d with an angle of 0.Rotation2d
(double theta) Create a new Rotation2d with the given angle in radians. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the Rotation2d.double
cos()
Returns the cosine of the angle.static Rotation2d
fromDegrees
(double degrees) Create a new Rotation2d with the given degrees.static Rotation2d
fromRadians
(double radians) Create a new Rotation2d with the given radians.double
Returns the angle in degrees.double
Returns the angle in radians.double
getTheta()
Returns the angle in radians.inverse()
Returns the inverse of the angle.normal()
Returns the normal of the angle (adding 90 degrees).rotateBy
(Rotation2d other) Rotate the angle by the given angle.void
setTheta
(double theta) Sets the angle in radians.double
sin()
Returns the sine of the angle.double
tan()
Returns the tangent of the angle.toVector()
Converts the angle to a vector (unit vector).Converts the angle to a 3D vector (unit vector).static Rotation2d
zero()
Create a new Rotation2d with an angle of 0.
-
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
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
Returns the normal of the angle (adding 90 degrees).- Returns:
- A new Rotation2d with the angle normal to the current angle.
-
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
Converts the angle to a vector (unit vector).- Returns:
- A new Vector2d equivalent to the angle / in the direction of the angle.
-
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
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
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
Create a new Rotation2d with an angle of 0.- Returns:
- A new Rotation2d with an angle of 0.
-
clone
Clone the Rotation2d.
-