Angle
An angle, represented both in degrees and radians. Angle objects are designed to replace primitives, such as doubles, wherever any angles are used. Because Pathfinder is so heavily focused on geometry, the Angle class is designed to accommodate for just about whatever angle-related things you can think of. Super cool!
It's strongly suggested that you use the Angle class just about anywhere you would use an angle. Although yes, it is technically slower and requires more memory to use objects instead of just using primitives, such as double, it keeps your code readable and makes it easier to modify down the line. Also, if you're planning on making any changes to Pathfinder2's source code, ALL angles should be denoted using the Angle class. There should be next to no primitives whatsoever.
In addition to tons of cool and very epic math stuff, the Angle class provides some formatting utilities. See:
formatAsDegLong()formatAsDegShort()formatAsRadLong()formatAsRadShort()
This class was created primarily to simplify operations related to angles. Much of the trigonometry previously delegated to Math has been made available, such as...
sin()cos()tan()csc()sec()cot()asin(double)acos(double)atan(double)atan2(double, double)
Additionally, because Angle objects store both degrees and radians measures of the angle, you can use whichever you'd prefer.
deg()- angle in degreesrad()- angle in radians
Finally, one of the key features of the Angle class is the ability to create so-called "fixed" angles. A fixed angle is an angle that fits within some certain bounds. Both the degree and radian representations of the angle will fit within the bounds 0-360 and 0-2pi respectively. To access these fixed angles, see...
fixDeg(double)- fix degrees measurementfixRad(double)- fix radians measurementfixed(AngleUnit, double)- create fixed anglefixedDeg(double)- create fixed angle from degreesfixedRad(double)- create fixed angle from radiansfixedFlip()- add 180 degrees to the current anglefixedRotateDeg(Angle, double)fixedRotateRad(Angle, double)
Methods
fromTrig(double sin, double cos)
Creates an angle from a sine and cosine value.
parse(String string)
Parses an angle from a string.
fix(double value, double min, double max, double max10)
Fixes a value to be within a certain range.
fixRad(double rad)
Fixes a radian value to be within the range of 0-2pi.
fixDeg(double deg)
Fixes a degree value to be within the range of 0-360.
fromRad(double rad)
Creates an angle from a radian value.
fromDeg(double deg)
Creates an angle from a degree value.
rad(double rad)
Creates an angle from a radian value.
deg(double deg)
Creates an angle from a degree value.
fixedRad(double rad)
Creates a fixed angle from a radian value.
fixedDeg(double deg)
Creates a fixed angle from a degree value.
fromRotations(double rotations)
Creates an angle from a number of rotations.
fixedRotations(double rotations)
Creates a fixed angle from a number of rotations.
angle(AngleUnit unit, double value)
Creates an angle from a value and a unit.
fixed(AngleUnit unit, double value)
Creates a fixed angle from a value and a unit.
add(Angle a, Angle b)
Adds two angles together.
subtract(Angle a, Angle b)
Subtracts two angles.
multiply(Angle a, Angle b)
Multiplies two angles together.
multiply(Angle a, double b)
Multiplies an angle by a number.
zero()
Creates a zero angle.
equals(Angle a, Angle b)
Checks if two angles are equal.
equals(Object objA, Object objB)
Checks if two objects are equal angles.
isCloseRad(Angle a, Angle b, double tolerance)
Checks if two angles are close in radians.
isCloseDeg(Angle a, Angle b, double tolerance)
Checks if two angles are close in degrees.
minimumDelta(Angle a, Angle b)
Gets the minimum delta between two angles.
angleDelta(Angle a, Angle b)
Gets the minimum delta between two angles.
angleDeltaDeg(Angle a, Angle b)
Gets the minimum delta between two angles in degrees.
angleDeltaRad(Angle a, Angle b)
Gets the minimum delta between two angles in radians.
acos(double a)
Creates an angle from the Math.acos(double) method.
asin(double a)
Creates an angle from the Math.asin(double) method.
atan(double a)
Creates an angle from the Math.atan(double) method.
atan2(double y, double x)
Creates an angle from the Math.atan2(double, double) method.
rotateRad(Angle a, double rad)
Rotates an angle by a given amount of radians.
rotateDeg(Angle a, double deg)
Rotates an angle by a given amount of degrees.
fixedRotateRad(Angle a, double rad)
Rotates an angle by a given amount of radians and fixes it.
fixedRotateDeg(Angle a, double deg)
Rotates an angle by a given amount of degrees and fixes it.
flip(Angle a)
Flips an angle (adds 180 degrees).
fixedFlip(Angle a)
Flips an angle and fixes it.
toDeg(double rad)
Converts radians to degrees.
toRad(double deg)
Converts degrees to radians.
checkArgument(Angle angle, String message)
Checks if an angle is null.
checkArgument(Angle angle)
Checks if an angle is null.
rad()
Gets the angle's value in radians.
deg()
Gets the angle's value in degrees.
sin()
Gets the sine of the angle.
cos()
Gets the cosine of the angle.
tan()
Gets the tangent of the angle.
csc()
Gets the cosecant of the angle.
sec()
Gets the secant of the angle.
cot()
Gets the cotangent of the angle.
add(Angle a)
Adds an angle to this angle.
subtract(Angle a)
Subtracts an angle from this angle.
multiply(Angle a)
Multiplies an angle by an angle.
multiply(double a)
Multiplies an angle by a number.
equals(Angle a)
Checks if two angles are equal.
isCloseRad(Angle a, double tolerance)
Checks if two angles are close in radians.
isCloseDeg(Angle a, double tolerance)
Checks if two angles are close in degrees.
rotateRad(double rad)
Rotates an angle by a given amount of radians.
rotateDeg(double deg)
Rotates an angle by a given amount of degrees.
fixedRotateRad(double rad)
Rotates an angle by a given amount of radians and fixes it.
fixedRotateDeg(double deg)
Rotates an angle by a given amount of degrees and fixes it.
flip()
Flips an angle (adds 180 degrees).
fixedFlip()
Flips an angle and fixes it.
fix()
Fixes the current angle.
rotate45Deg()
Rotates the angle by 45 degrees.
rotate90Deg()
Rotates the angle by 90 degrees.
rotate180Deg()
Rotates the angle by 180 degrees.
fixedRotate45Deg()
Rotates the angle by 45 degrees and fixes it.
fixedRotate90Deg()
Rotates the angle by 90 degrees and fixes it.
fixedRotate180Deg()
Rotates the angle by 180 degrees and fixes it.
formatAsRadShort()
Formats the angle as "? rad".
formatAsDegShort()
Formats the angle as "? deg".
formatAsRadLong()
Formats the angle as "? radians".
formatAsDegLong()
Formats the angle as "? degrees".
lessThan(Angle angle)
Checks if this angle is less than the provided angle.
greaterThan(Angle angle)
Checks if this angle is greater than the provided angle.
lessThanOrEqualTo(Angle angle)
Checks if this angle is less than or equal to the provided angle.
greaterThanOrEqualTo(Angle angle)
Checks if this angle is greater than or equal to the provided angle.
angleWithMinAndMax(Angle minimum, Angle maximum)
If this angle is less than the minimum angle, return the minimum angle. If this angle is greater than the maximum angle, return the maximum angle. If this angle is neither, return this angle.
toTranslation()
Converts this Angle into a translation.
toTranslation(double vz)
Converts this Angle into a translation.
toTranslation(double translationMagnitude, double vz)
Converts this Angle into a translation.
compareTo(Angle o)
Compares two angles.
toString()
Converts the angle to a string.
hashCode()
Gets the hash code of the angle.
equals(Object obj)
Checks if two objects are equal angles.