agi.foundation
(agi.foundation.core-2020r1.jar)

## Class Trig

• ```public final class Trig
extends Object```
Provides functions and constants which are useful when working with angles and solving problems related to trigonometry.
• ### Field Summary

Fields
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.
• ### Method Summary

All Methods
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 deg)`
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 -Pi < angle <= Pi 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 < 2Pi which is equivalent to the provided angle.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

`public static double degreesToRadians(double deg)`
Converts degrees to radians.
Parameters:
`deg` - The angle to convert in degrees.
Returns:
The corresponding angle in radians.

`public static double radiansToDegrees(double angle)`
Converts radians to degrees.
Parameters:
`angle` - The angle to convert in radians.
Returns:
The corresponding angle in degrees.

```public static double degreesMinutesSecondsToRadians(int revolutions,
int degrees,
int minutes,
double seconds)```
Converts the specified number of revolutions, degrees, minutes, and seconds to radians.
Parameters:
`revolutions` - The number of complete (360 degree) revolutions.
`degrees` - The number of degrees.
`minutes` - The number of minutes.
`seconds` - The number of seconds.
Returns:
The corresponding angle in radians.

```public static double degreesMinutesSecondsToRadians(@Nonnull
DegreesMinutesSeconds dms)```
Converts the specified number of revolutions, degrees, minutes, and seconds to radians.
Parameters:
`dms` - The `DegreesMinutesSeconds` to be converted to radians.
Returns:
The corresponding angle in radians.

```@Nonnull
Converts the specified angle in radians to revolutions, degrees, minutes, and seconds.
Parameters:
`radians` - The angle in radians
Returns:
The corresponding angle in DMS.
• #### zeroToTwoPi

`public static double zeroToTwoPi(double angle)`
Produces an angle in the range 0 <= angle < 2Pi which is equivalent to the provided angle.
Parameters:
`angle` - The angle to be adjusted.
Returns:
• #### negativePiToPi

`public static double negativePiToPi(double angle)`
Produces an angle in the range -Pi < angle <= Pi which is equivalent to the provided angle.
Parameters:
`angle` - The angle to be adjusted.
Returns:
• #### tryPutAngleInRange

```public static boolean tryPutAngleInRange(double minimum,
double maximum,
double angle,
@Nonnull
double[] result)```
Attempts to put an angle within the indicated range of values.

The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.

Parameters:
`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.
Returns:
`true` if `result` is within the indicated range of values; otherwise `false`.
`Trig.isAngleInRange(double, double, double)`, `Trig.putAngleInRange(double, double, double)`
• #### isAngleInRange

```public static boolean isAngleInRange(double minimum,
double maximum,
double angle)```
Checks to see if an angle is within the indicated range of values.

The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.

Parameters:
`minimum` - The minimum angle value.
`maximum` - The maximum angle value.
`angle` - The angle value being checked.
Returns:
`true` if `angle` is within the indicated range of values; otherwise `false`.
`Trig.putAngleInRange(double, double, double)`, `Trig.tryPutAngleInRange(double, double, double, double[])`
• #### putAngleInRange

```public static double putAngleInRange(double minimum,
double maximum,
double angle)```
Attempts to put an angle within the indicated range of values.

The range of values is considered to be an open interval and therefore does not include the actual minimum and maximum values.

Parameters:
`minimum` - The minimum angle value.
`maximum` - The maximum angle value.
`angle` - The angle value being checked.
Returns:
The final angle value after attempting to place it within the indicated range.
Throws:
`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[])`
• #### getSmallSpan

```public static double getSmallSpan(double startAngle,
double stopAngle)```
Get the signed small span between two arbitrary angles, in radians. This will return the angle in radians between minus Pi and Pi representing the angular distance between the two given angles. It will remove the effect of 'winding' and compare the angular distance on the unit circle.

As an example, if the angles are 1.0 (`startAngle`) and 2*Pi (`stopAngle`) then the simple difference will be 2*Pi - 1.0 and the "small span" would be -1.0

Parameters:
`startAngle` - The first angle, in radians.
`stopAngle` - The second angle, in radians.
Returns:
The signed small span between the two angles, in radians.
• #### areAnglesEquivalent

```public 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`.
Parameters:
`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.
Returns:
True if the two angles represent the same angular direction in the unit circle.