Package craterdog.primitives
Class Angle
- All Implemented Interfaces:
Atomic<Angle>
,Comparable<Angle>
This class encapsulates radian based angles. It normalizes all angles to the range [-pi..pi).
- Author:
- Derk Norton
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Angle
arccosine(double ratio)
This function returns the angle whose cosine is the specified ratio.static Angle
arcsine(double ratio)
This function returns the angle whose sine is the specified ratio.static Angle
arctangent(double ratio)
This function returns the angle whose tangent is the specified ratio.static Angle
arctangent(double y, double x)
This function returns the angle whose tangent is the ratio of the specified values.int
static double
This function returns the cosine of the specified angle.static Angle
difference(Angle angle1, Angle angle2)
This function returns the normalized difference of two angles.boolean
int
hashCode()
static Angle
This function returns the normalized inversion of the specified angle.static Angle
This function returns the normalized negation of the specified angle.static Angle
This function returns the normalized product of an angle and a scalar value.static Angle
This function returns the normalized quotient of an angle and a scalar value.static double
This function returns the sine of the specified angle.static Angle
This function returns the normalized sum of two angles.static double
This function returns the tangent of the specified angle.double
toDouble()
This method returns the value of the angle as a double.toString()
-
Field Details
-
PI
This constant approximates the value of pi.
-
-
Constructor Details
-
Angle
public Angle()This default constructor creates an angle with a default value of zero radians. -
Angle
public Angle(double value)This constructor creates an angle with the specified value in radians. If the value is outside the range (-pi..pi] then the value is normalize to be within this range.- Parameters:
value
- The value of the new angle.
-
Angle
This constructor creates an angle with the specified value in radians. If the value is outside the range (-pi..pi] then the value is normalize to be within this range.- Parameters:
string
- The string value of the new angle.
-
-
Method Details
-
compareTo
-
equals
-
hashCode
public int hashCode() -
toString
-
toDouble
public double toDouble()This method returns the value of the angle as a double.- Returns:
- The value of the angle.
-
inverse
This function returns the normalized inversion of the specified angle. The value of the inverted angle is angle - pi.- Parameters:
angle
- The angle.- Returns:
- The inverted angle.
-
negative
This function returns the normalized negation of the specified angle. The value of the negated angle is -angle.- Parameters:
angle
- The angle.- Returns:
- The negated angle.
-
sum
This function returns the normalized sum of two angles.- Parameters:
angle1
- The first angle.angle2
- The second angle.- Returns:
- The sum of the two angles.
-
difference
This function returns the normalized difference of two angles.- Parameters:
angle1
- The first angle.angle2
- The second angle.- Returns:
- The difference of the two angles.
-
product
This function returns the normalized product of an angle and a scalar value.- Parameters:
angle
- The angle.multiplier
- The scalar value.- Returns:
- The product of the angle and scalar value.
-
quotient
This function returns the normalized quotient of an angle and a scalar value.- Parameters:
angle
- The angle.divisor
- The scalar value.- Returns:
- The quotient of the angle and scalar value.
-
sine
This function returns the sine of the specified angle.- Parameters:
angle
- The angle.- Returns:
- The sine of the angle.
-
arcsine
This function returns the angle whose sine is the specified ratio.- Parameters:
ratio
- The ratio of the opposite over the hypotenuse.- Returns:
- The arcsine of the ratio.
-
cosine
This function returns the cosine of the specified angle.- Parameters:
angle
- The angle.- Returns:
- The cosine of the angle.
-
arccosine
This function returns the angle whose cosine is the specified ratio.- Parameters:
ratio
- The ratio of the adjacent over the hypotenuse.- Returns:
- The arccosine of the ratio.
-
tangent
This function returns the tangent of the specified angle.- Parameters:
angle
- The angle.- Returns:
- The tangent of the angle.
-
arctangent
This function returns the angle whose tangent is the specified ratio.- Parameters:
ratio
- The ratio of the opposite over the adjacent.- Returns:
- The arctangent of the ratio.
-
arctangent
This function returns the angle whose tangent is the ratio of the specified values.- Parameters:
y
- The y coordinate.x
- The x coordinate.- Returns:
- The arctangent of the ratio.
-