public final class Angle
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
DEGREES_TO_RADIANS
The factor that converts an angle from degrees to radians.
|
static double |
RADIANS_TO_DEGREES
The factor that converts an angle from radians to degrees.
|
Modifier and Type | Method and Description |
---|---|
static Compass |
degreesToCompass(double degrees)
Converts the specified angle in degrees to the nearest
Compass point. |
static double |
distanceDegrees(double start,
double end)
Finds the shortest distance between two specified normalized angles, in degrees.
|
static double |
distanceRadians(double start,
double end)
Finds the shortest distance between two specified normalized angles, in radians.
|
static double |
normalizeDegrees(double degrees)
Normalizes the specified angle in degrees to the interval [0, 360).
|
static double |
normalizeRadians(double radians)
Normalizes the specified angle in radians to the interval [0, 2
Math.PI ). |
static int |
normalizeRoundedDegrees(double degrees)
Normalizes the specified angle in degrees to the interval [0, 360),
after rounding to the nearest
Integer . |
public static final double DEGREES_TO_RADIANS
Math.PI
/ 180.public static final double RADIANS_TO_DEGREES
Math.PI
.public static Compass degreesToCompass(double degrees)
Compass
point.degrees
- the angle in degrees to convert. This value is taken Fortran.modulo(double, double)
360 degrees, and may therefore lie outside the interval [0, 360).Compass
point nearest the specified degrees
public static double distanceDegrees(double start, double end)
normalizeDegrees(double)
. If so, distanceDegrees
returns the value
within the half-open interval (-180, 180] that solves the following equation:
end
= normalizeDegrees(double)
(start
+
distanceDegrees
(start
, end
))start
- the angle from which the distance is measured, in normalized degreesend
- the angle to which the distance is measured, in normalized degreesstart
and end
, in signed degreespublic static double distanceRadians(double start, double end)
Math.PI
),
e.g. using normalizeRadians(double)
. If so, distanceRadians
returns the value within
the half-open interval (-Math.PI
, Math.PI
] that solves the following equation:
end
= normalizeRadians(double)
(start
+
distanceRadians
(start
, end
))start
- the angle from which the distance is measured, in normalized radiansend
- the angle to which the distance is measured, in normalized radiansstart
and end
, in signed radianspublic static double normalizeDegrees(double degrees)
degrees
- the angle in degrees to normalizedegrees
normalized to the half-open interval [0, 360)public static int normalizeRoundedDegrees(double degrees)
Integer
.
Uses Fortran.nint(double)
to round degrees
before normalization.
The result is guaranteed to be an Integer
value within [0, 359].degrees
- the angle in degrees to normalizedegrees
rounded to the nearest Integer
and normalized to the half-open interval [0, 360)java.lang.ArithmeticException
- if degrees
overflows Integer
public static double normalizeRadians(double radians)
Math.PI
).radians
- the angle in radians to normalizeradians
normalized to the half-open interval [0, 2 Math.PI
)