public final class Trig extends Object
Modifier and Type | Field and Description |
---|---|
static double |
AngleEpsilon
Represents the smallest positive angle greater than zero for which the
Math.cos(double) function will produce a distinct value. |
Modifier and Type | Method and Description |
---|---|
static boolean |
areAnglesEquivalent(double firstAngle,
double secondAngle,
double tolerance)
Checks to see whether the two given angles represent the same direction in the unit circle,
regardless of any multiples of
Constants.TwoPi . |
static double |
degreesMinutesSecondsToRadians(DegreesMinutesSeconds dms)
Converts the specified number of revolutions, degrees, minutes, and seconds to radians.
|
static double |
degreesMinutesSecondsToRadians(int revolutions,
int degrees,
int minutes,
double seconds)
Converts the specified number of revolutions, degrees, minutes, and seconds to radians.
|
static double |
degreesToRadians(double angle)
Converts degrees to radians.
|
static double |
getSmallSpan(double startAngle,
double stopAngle)
Get the signed small span between two arbitrary angles, in radians.
|
static boolean |
isAngleInRange(double minimum,
double maximum,
double angle)
Checks to see if an angle is within the indicated range of values.
|
static double |
negativePiToPi(double angle)
Produces an angle in the range -π < angle <= π which is equivalent to the provided angle.
|
static double |
putAngleInRange(double minimum,
double maximum,
double angle)
Attempts to put an angle within the indicated range of values.
|
static double |
radiansToDegrees(double angle)
Converts radians to degrees.
|
static DegreesMinutesSeconds |
radiansToDegreesMinutesSeconds(double radians)
Converts the specified angle in radians to revolutions, degrees, minutes, and seconds.
|
static boolean |
tryPutAngleInRange(double minimum,
double maximum,
double angle,
double[] result)
Attempts to put an angle within the indicated range of values.
|
static double |
zeroToTwoPi(double angle)
Produces an angle in the range 0 <= angle < 2π which is equivalent to the provided angle.
|
public static final double AngleEpsilon
Math.cos(double)
function will produce a distinct value.
For angles smaller than this value, the Math.cos(double)
function returns 1.0.
public static double degreesToRadians(double angle)
angle
- The angle to convert in degrees.public static double radiansToDegrees(double angle)
angle
- The angle to convert in radians.public static double degreesMinutesSecondsToRadians(int revolutions, int degrees, int minutes, double seconds)
revolutions
- The number of complete (360 degree) revolutions.degrees
- The number of degrees.minutes
- The number of minutes.seconds
- The number of seconds.public static double degreesMinutesSecondsToRadians(@Nonnull DegreesMinutesSeconds dms)
dms
- The DegreesMinutesSeconds
to be converted to radians.@Nonnull public static DegreesMinutesSeconds radiansToDegreesMinutesSeconds(double radians)
radians
- The angle in radianspublic static double zeroToTwoPi(double angle)
angle
- The angle to be adjusted.public static double negativePiToPi(double angle)
angle
- The angle to be adjusted.public static boolean tryPutAngleInRange(double minimum, double maximum, double angle, @Nonnull double[] result)
The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.
minimum
- The minimum angle value.maximum
- The maximum angle value.angle
- The angle value being checked.result
- On input, an array with one element. On return, the array is populated with
the final angle value after attempting to place it within the indicated range.true
if result
is within the indicated range of values; otherwise false
.Trig.isAngleInRange(double, double, double)
,
Trig.putAngleInRange(double, double, double)
public static boolean isAngleInRange(double minimum, double maximum, double angle)
The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.
minimum
- The minimum angle value.maximum
- The maximum angle value.angle
- The angle value being checked.true
if angle
is within the indicated range of values; otherwise false
.Trig.putAngleInRange(double, double, double)
,
Trig.tryPutAngleInRange(double, double, double, double[])
public static double putAngleInRange(double minimum, double maximum, double angle)
The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.
minimum
- The minimum angle value.maximum
- The maximum angle value.angle
- The angle value being checked.ArgumentOutOfRangeException
- Thrown if the value of angle
cannot be placed within the open interval defined by the specified minimum
and maximum
.Trig.isAngleInRange(double, double, double)
,
Trig.tryPutAngleInRange(double, double, double, double[])
public static double getSmallSpan(double startAngle, double stopAngle)
As an example, if startAngle
is 1.0 and
stopAngle
is 2π, then the simple difference
will be 2π - 1.0 and the "small span" would be -1.0.
startAngle
- The first angle, in radians.stopAngle
- The second angle, in radians.public static boolean areAnglesEquivalent(double firstAngle, double secondAngle, double tolerance)
Constants.TwoPi
.firstAngle
- The first angle to check, in radians.secondAngle
- The second angle to check, in radians.tolerance
- The tolerance to use when comparing the two angles, in radians.