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.DoubleSupplier
Represents the angle concept.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Angle.Deg
Unit: degrees.private static class
Angle.Normalizer
Normalizes an angle around a center value.static class
Angle.Rad
Unit: radians.static class
Angle.Turn
Unit: turns.
-
Field Summary
Fields Modifier and Type Field Description private static double
DEG_TO_RAD
Degrees to radians conversion factor.static double
PI_OVER_TWO
π/2.private static double
RAD_TO_DEG
Radians to degrees conversion factor.private static double
TURN_TO_DEG
Turns to degrees conversion factor.static double
TWO_PI
2π.private double
value
Value (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 boolean
equals(java.lang.Object other)
Test for equality with another object.double
getAsDouble()
int
hashCode()
abstract Angle.Deg
toDeg()
Convert to aAngle.Deg
.abstract Angle.Rad
toRad()
Convert to aAngle.Rad
.abstract Angle.Turn
toTurn()
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:
getAsDouble
in interfacejava.util.function.DoubleSupplier
- Returns:
- the value.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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:
equals
in classjava.lang.Object
- Parameters:
other
- Object to test for equality with this instance.- Returns:
true
if the objects are equal,false
ifother
isnull
, 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.
-
-