@XStreamConverter(value=Rotation2D.MyConverter.class) public final class Rotation2D extends Object implements Comparable<Rotation2D>, Serializable
(cos(theta), sin(theta))where
theta
is the angle.
Objects of this class are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
Rotation2D.MyConverter |
Modifier and Type | Field and Description |
---|---|
static Rotation2D |
EIGHTH
The rotation of an eighth revolution.
|
static Rotation2D |
HALF
The rotation of a half revolution.
|
static Rotation2D |
QUARTER
The rotation of a quarter revolution.
|
static Rotation2D |
ZERO
The identity rotation.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Rotation2D o) |
boolean |
equals(Object obj) |
static Rotation2D |
fromAngle(double theta)
Returns the rotation which is equal to the given angle.
|
static Rotation2D |
fromBetween(Double2D direction1,
Double2D direction2)
Creates a rotation from
direction1 to direction2 . |
static Rotation2D |
fromVector(Double2D vector)
Creates a rotation from a direction vector.
|
double |
getCos()
Returns the cosine of this rotation.
|
double |
getSin()
Returns the sine of this rotation.
|
Double2D |
getVector()
Returns the rotation as direction vector.
|
int |
hashCode() |
boolean |
isClockwise()
Returns
true if the shortest path following this rotation is
clockwise. |
Double2D |
multiply(Double2D vector)
Applies this rotation on a vector by rotating around its origin.
|
Rotation2D |
multiply(Rotation2D other)
Concatenates this rotation with another rotation.
|
Rotation2D |
nlerp(Rotation2D other,
double t)
Performs a linear interpolation between the vectors of this rotation and
the other.
|
Rotation2D |
opposite()
Returns the opposite of this direction.
|
Rotation2D |
slerp(Rotation2D other,
double t)
Performs a spherical linear interpolation between this rotation and the
other.
|
double |
toAngle()
Returns the angle of this rotation in radians.
|
String |
toString() |
public static final Rotation2D ZERO
public static final Rotation2D EIGHTH
public static final Rotation2D QUARTER
public static final Rotation2D HALF
public Rotation2D multiply(Rotation2D other)
other
- the other rotationpublic Double2D multiply(Double2D vector)
vector
- the vector to rotatepublic Rotation2D opposite()
public Rotation2D nlerp(Rotation2D other, double t)
other
- the other rotationt
- the interpolation parameterArithmeticException
- if rotations are oppositepublic Rotation2D slerp(Rotation2D other, double t)
other
- the other rotationt
- the interpolation parameterpublic boolean isClockwise()
true
if the shortest path following this rotation is
clockwise. Otherwise, false
is returnedtrue
if clockwisepublic double toAngle()
public Double2D getVector()
public static Rotation2D fromAngle(double theta)
theta
- the angle in radianspublic static Rotation2D fromVector(Double2D vector)
NOTE: The vector must be of unit length. Otherwise the resulting rotation is invalid.
vector
- the direction unit vectorpublic static Rotation2D fromBetween(Double2D direction1, Double2D direction2)
direction1
to direction2
.
NOTE: Both vectors must be of unit length. Otherwise the resulting rotation is invalid.
direction1
- direction2
- public double getCos()
public double getSin()
public int compareTo(Rotation2D o)
compareTo
in interface Comparable<Rotation2D>