Package org.apache.commons.numbers.angle
Class Angle
- java.lang.Object
-
- org.apache.commons.numbers.angle.Angle
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
- Direct Known Subclasses:
Angle.Deg,Angle.Rad,Angle.Turn
public abstract class Angle extends java.lang.Object implements java.util.function.DoubleSupplierRepresents the angle concept.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAngle.DegUnit: degrees.private static classAngle.NormalizerNormalizes an angle around a center value.static classAngle.RadUnit: radians.static classAngle.TurnUnit: turns.
-
Field Summary
Fields Modifier and Type Field Description private static doubleDEG_TO_RADDegrees to radians conversion factor.static doublePI_OVER_TWOπ/2.private static doubleRAD_TO_DEGRadians to degrees conversion factor.private static doubleTURN_TO_DEGTurns to degrees conversion factor.static doubleTWO_PI2π.private doublevalueValue (unit depends on concrete instance).
-
Constructor Summary
Constructors Constructor Description Angle(double value)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)Test for equality with another object.doublegetAsDouble()inthashCode()abstract Angle.DegtoDeg()Convert to aAngle.Deg.abstract Angle.RadtoRad()Convert to aAngle.Rad.abstract Angle.TurntoTurn()Convert to aAngle.Turn.
-
-
-
Field Detail
-
TWO_PI
public static final double TWO_PI
2π.- See Also:
- Constant Field Values
-
PI_OVER_TWO
public static final double PI_OVER_TWO
π/2.- See Also:
- Constant Field Values
-
TURN_TO_DEG
private static final double TURN_TO_DEG
Turns to degrees conversion factor.- See Also:
- Constant Field Values
-
RAD_TO_DEG
private static final double RAD_TO_DEG
Radians to degrees conversion factor.- See Also:
- Constant Field Values
-
DEG_TO_RAD
private static final double DEG_TO_RAD
Degrees to radians conversion factor.- See Also:
- Constant Field Values
-
value
private final double value
Value (unit depends on concrete instance).
-
-
Method Detail
-
getAsDouble
public double getAsDouble()
- Specified by:
getAsDoublein interfacejava.util.function.DoubleSupplier- Returns:
- the value.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
Test for equality with another object. Objects are considered to be equal if their concrete types are equal and their values are exactly the same (or both areDouble.NaN).- Overrides:
equalsin classjava.lang.Object- Parameters:
other- Object to test for equality with this instance.- Returns:
trueif the objects are equal,falseifotherisnull, not of the same type as this instance, or not equal to this instance.
-
toTurn
public abstract Angle.Turn toTurn()
Convert to aAngle.Turn.- Returns:
- the angle in turns.
-
-