public class Rotation
extends java.lang.Object
Constructor and Description |
---|
Rotation()
Default constructor: rotation matrix of angle 0
|
Rotation(double cos,
double sin) |
Rotation(double cos,
double sin,
boolean normalize)
Create a rotation matrix from the sin and cos of the angle.
|
Rotation(Translation directionVector)
Create a rotation matrix from a translation vector.
|
Modifier and Type | Method and Description |
---|---|
double |
cos() |
double |
degrees() |
static Rotation |
fromDegrees(double degrees) |
static Rotation |
fromRadians(double radians) |
Rotation |
inverse()
Calculates the inverse of this rotation matrix
Basically what when multiplied after this matrix will turn it into the identity matrix
In other words, it's the rotation matrix representing the angle that is the opposite of this angle
|
Rotation |
normal()
Calculates the Normal or perpendicular rotation matrix to the angle of this rotation matrix
Example: If this represents a rotation matrix of 0 degrees, normal will return a rotation matrix for 90 degrees
|
double |
radians()
Returns between -pi and pi
|
Rotation |
rotate(Rotation other)
Rotates this rotation matrix by a specified angle
|
double |
sin() |
double |
tan() |
java.lang.String |
toString() |
public Rotation(double cos, double sin, boolean normalize)
cos
- cos of the angle of the rotationsin
- sin of the angle of the rotationnormalize
- whether or not we should "normalize" this rotation normalize()
public Rotation(double cos, double sin)
public Rotation()
public Rotation(Translation directionVector)
directionVector
- the translation vector to calculate the angle frompublic static Rotation fromRadians(double radians)
public static Rotation fromDegrees(double degrees)
public double cos()
public double sin()
public double tan()
public double radians()
public double degrees()
public Rotation normal()
public Rotation rotate(Rotation other)
Basically multiplies the specified rotation matrix after this rotation matrix
[[cos', -sin'] = [[cos_0, -sin_0] * [[cos_1, -sin_1] = [[cos_0*cos_1+(-sin_0)*sin_1, cos_0*(-sin_1)+(-sin_0)*cos_1] [sin', cos']] [sin_0, cos_0]] [sin_1, cos_1]] [sin_0*cos_1+cos_0*sin_1, sin_0*(-sin_1)+cos_0*cos_1 ]] So for implementation purposes, basically: cos' = cos_0*cos_1+(-sin_0)*sin_1 sin' = sin_0*cos_1+cos_0*sin_1
other
- Angle to rotate this rotation matrix bypublic Rotation inverse()
Since rotation matrices are orthagonal matrices, the inverse is the same as the transpose Calculating the transpose is much cheaper than calculating the inverse
[[cos, -sin]T = [[cos, sin] [sin, cos]] [-sin, cos]]
For implementation purposes, cos' = cos sin' = -sin
public java.lang.String toString()
toString
in class java.lang.Object