public class Angle extends java.lang.Object implements java.lang.Comparable<Angle>
Angle
are immutable. An angle can be obtained through the
factory methods fromDegrees(double)
and fromRadians(double)
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANGLE_FORMAT_DD |
static java.lang.String |
ANGLE_FORMAT_DM |
static java.lang.String |
ANGLE_FORMAT_DMS |
double |
degrees |
static Angle |
MINUTE
Represents an angle of 1 minute
|
static Angle |
NEG180
Represents an angle of negative 180 degrees
|
static Angle |
NEG360
Represents an angle of negative 360 degrees
|
static Angle |
NEG90
Represents a right angle of negative 90 degrees
|
static Angle |
POS180
Represents an angle of positive 180 degrees
|
static Angle |
POS360
Represents an angle of positive 360 degrees
|
static Angle |
POS90
Represents a right angle of positive 90 degrees
|
double |
radians |
static Angle |
SECOND
Represents an angle of 1 second
|
static Angle |
ZERO
Represents an angle of zero degrees
|
Modifier and Type | Method and Description |
---|---|
static Angle |
acos(double cosine) |
Angle |
add(Angle angle)
Obtains the sum of these two angles.
|
Angle |
addDegrees(double degrees) |
Angle |
addRadians(double radians) |
Angle |
angularDistanceTo(Angle angle)
Computes the shortest distance between this and angle, as an angle.
|
static double |
arctanh(double radians) |
static Angle |
asin(double sine) |
static Angle |
atan(double tan) |
static Angle |
average(Angle a,
Angle b)
Obtains the average of three angles.
|
static Angle |
average(Angle a,
Angle b,
Angle c)
Obtains the average of three angles.
|
static Angle |
clamp(Angle value,
Angle min,
Angle max)
Limits a specified angle to be within a specified minimum and maximum.
|
int |
compareTo(Angle angle)
Compares this
Angle with another. |
double |
cos()
Obtains the cosine of this angle.
|
double |
cosHalfAngle() |
static boolean |
crossesLongitudeBoundary(Angle angleA,
Angle angleB) |
double |
divide(Angle angle)
Divides this angle by another angle.
|
Angle |
divide(double divisor)
Divides this angle by
divisor . |
boolean |
equals(java.lang.Object o) |
static Angle |
fromDegrees(double degrees)
Obtains an angle from a specified number of degrees.
|
static Angle |
fromDegreesLatitude(double degrees) |
static Angle |
fromDegreesLongitude(double degrees) |
static Angle |
fromDMdS(int degrees,
double minutes)
Obtain an angle from a given number of positive degrees and decimal minutes.
|
static Angle |
fromDMS(int degrees,
int minutes,
int seconds)
Obtain an angle from a given number of positive degrees, minutes and seconds.
|
static Angle |
fromDMS(java.lang.String dmsString)
Obtain an angle from a degrees, minute and seconds character string.
|
static Angle |
fromRadians(double radians)
Obtains an angle from a specified number of radians.
|
static Angle |
fromRadiansLatitude(double radians) |
static Angle |
fromRadiansLongitude(double radians) |
static Angle |
fromXY(double x,
double y)
Obtains an angle from rectangular coordinates.
|
double |
getDegrees()
Retrieves the size of this angle in degrees.
|
double |
getRadians()
Retrieves the size of this angle in radians.
|
long |
getSizeInBytes()
Obtains the amount of memory this
Angle consumes. |
int |
hashCode() |
static boolean |
isValidLatitude(double value) |
static boolean |
isValidLongitude(double value) |
static Angle |
max(Angle a,
Angle b) |
static Angle |
midAngle(Angle a1,
Angle a2)
Obtains the average of two angles.
|
static Angle |
min(Angle a,
Angle b) |
static Angle |
mix(double amount,
Angle value1,
Angle value2)
Linearly interpolates between two angles.
|
Angle |
multiply(double multiplier)
Multiplies this angle by
multiplier . |
Angle |
normalize() |
static Angle |
normalizedAngle(Angle unnormalizedAngle) |
static double |
normalizedDegrees(double degrees) |
static double |
normalizedDegreesLatitude(double degrees) |
static double |
normalizedDegreesLongitude(double degrees) |
Angle |
normalizedLatitude() |
static Angle |
normalizedLatitude(Angle unnormalizedAngle) |
Angle |
normalizedLongitude() |
static Angle |
normalizedLongitude(Angle unnormalizedAngle) |
double |
sin()
Obtains the sine of this angle.
|
double |
sinHalfAngle() |
Angle |
subtract(Angle angle)
Obtains the difference of these two angles.
|
Angle |
subtractDegrees(double degrees) |
Angle |
subtractRadians(double radians) |
double |
tanHalfAngle()
Obtains the tangent of half of this angle.
|
java.lang.String |
toDecimalDegreesString(int digits)
Forms a decimal degrees
String representation of this Angle . |
double[] |
toDMS() |
java.lang.String |
toDMSString()
Obtains a
String representation of this Angle formatted as degrees, minutes and seconds integer
values. |
java.lang.String |
toDMString()
Obtains a
String representation of this Angle formatted as degrees and decimal minutes. |
java.lang.String |
toFormattedDMSString() |
java.lang.String |
toString()
Obtains a
String representation of this angle. |
public static final java.lang.String ANGLE_FORMAT_DD
public static final java.lang.String ANGLE_FORMAT_DM
public static final java.lang.String ANGLE_FORMAT_DMS
public final double degrees
public static final Angle MINUTE
public static final Angle NEG180
public static final Angle NEG360
public static final Angle NEG90
public static final Angle POS180
public static final Angle POS360
public static final Angle POS90
public final double radians
public static final Angle SECOND
public static final Angle ZERO
public Angle(Angle angle)
public static Angle acos(double cosine)
public final Angle add(Angle angle)
a.add(b)
and b.add(a)
are equivalent. Neither this angle nor angle is changed, instead
the result is returned as a new angle.angle
- the angle to add to this one.java.lang.IllegalArgumentException
- if angle is null.public final Angle addDegrees(double degrees)
public final Angle addRadians(double radians)
public Angle angularDistanceTo(Angle angle)
angle
- the angle to measure angular distance to.value
.public static double arctanh(double radians)
public static Angle asin(double sine)
public static Angle atan(double tan)
public static Angle average(Angle a, Angle b)
a
- the first angle.b
- the second angle.a1
, a2
and a3
java.lang.IllegalArgumentException
- if a
or b
is nullpublic static Angle average(Angle a, Angle b, Angle c)
a
- the first angle.b
- the second angle.c
- the third angle.a1
, a2
and a3
.java.lang.IllegalArgumentException
- if a
, b
or c
is null.public static Angle clamp(Angle value, Angle min, Angle max)
value
- The angle to clamp.min
- The minimum angle to clamp to.max
- The maximum angle to clamp to.java.lang.IllegalArgumentException
- if any argument is null.public final int compareTo(Angle angle)
Angle
with another. Returns a negative integer if this is the smaller angle, a positive
integer if this is the larger, and zero if both angles are equal.compareTo
in interface java.lang.Comparable<Angle>
angle
- the angle to compare against.java.lang.IllegalArgumentException
- if angle is null.public final double cos()
public final double cosHalfAngle()
public final double divide(Angle angle)
angle
- the angle by which to divide.java.lang.IllegalArgumentException
- if angle is null.public final Angle divide(double divisor)
divisor
. This angle remains unchanged. The result is returned as a new angle.
Behaviour is undefined if divisor
equals zero.divisor
- the number to be divided by.divisor
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public static Angle fromDegrees(double degrees)
degrees
- the size in degrees of the angle to be obtaineddegrees
public static Angle fromDegreesLatitude(double degrees)
public static Angle fromDegreesLongitude(double degrees)
public static Angle fromDMdS(int degrees, double minutes)
degrees
- integer number of degrees, positive.minutes
- double representing the decimal representation of minutes and seconds.degrees
and decimal minutes
.java.lang.IllegalArgumentException
- if minutes or seconds are outside the 0-60 range or the degrees is negative.public static Angle fromDMS(int degrees, int minutes, int seconds)
degrees
- integer number of degrees, positive.minutes
- integer number of minutes, positive only between 0 and 60.seconds
- integer number of seconds, positive only between 0 and 60.degrees
, minutes
and
seconds
.java.lang.IllegalArgumentException
- if minutes or seconds are outside the 0-60 range or the degrees is negative.public static Angle fromDMS(java.lang.String dmsString)
eg:
123 34 42 -123* 34' 42" (where * stands for the degree symbol) +45* 12' 30" (where * stands for the degree symbol) 45 12 30 S 45 12 30 N For a string containing both a sign and compass direction, the compass direction will take precedence.
dmsString
- the degrees, minute and second character string.java.lang.IllegalArgumentException
- if dmsString is null or not properly formated.public static Angle fromRadians(double radians)
radians
- the size in radians of the angle to be obtained.radians
.public static Angle fromRadiansLatitude(double radians)
public static Angle fromRadiansLongitude(double radians)
public static Angle fromXY(double x, double y)
x
- the abscissa coordinate.y
- the ordinate coordinate.x
and y
.public final double getDegrees()
public final double getRadians()
java.lang.Math
functions, which
generally take radians as trigonometric arguments. This method may be faster that first obtaining the degrees and
then converting to radians.public long getSizeInBytes()
Angle
consumes.public int hashCode()
hashCode
in class java.lang.Object
public static boolean isValidLatitude(double value)
public static boolean isValidLongitude(double value)
public static Angle midAngle(Angle a1, Angle a2)
midAngle(m, n)
and
midAngle(n, m)
are equivalent.a1
- the first angle.a2
- the second angle.a1
and a2
throws IllegalArgumentException if either angle is
null.public static Angle mix(double amount, Angle value1, Angle value2)
amount
- the interpolant.value1
- the first angle.value2
- the second angle.value1
and value2
.public final Angle multiply(double multiplier)
multiplier
. This angle remains unchanged. The result is returned as a new
angle.multiplier
- a scalar by which this angle is multiplied.multiplier
.public Angle normalize()
public static double normalizedDegrees(double degrees)
public static double normalizedDegreesLatitude(double degrees)
public static double normalizedDegreesLongitude(double degrees)
public Angle normalizedLatitude()
public Angle normalizedLongitude()
public final double sin()
public final double sinHalfAngle()
public final Angle subtract(Angle angle)
angle
- the angle to subtract from this angle.java.lang.IllegalArgumentException
- if angle is null.public final Angle subtractDegrees(double degrees)
public final Angle subtractRadians(double radians)
public final double tanHalfAngle()
public final java.lang.String toDecimalDegreesString(int digits)
String
representation of this Angle
.digits
- the number of digits past the decimal point to include in the string.public final double[] toDMS()
public final java.lang.String toDMSString()
String
representation of this Angle
formatted as degrees, minutes and seconds integer
values.public final java.lang.String toDMString()
String
representation of this Angle
formatted as degrees and decimal minutes.public final java.lang.String toFormattedDMSString()
public final java.lang.String toString()
String
representation of this angle.toString
in class java.lang.Object
String
.