NASA World Wind

gov.nasa.worldwind.geom
Class Angle

java.lang.Object
  extended by gov.nasa.worldwind.geom.Angle
All Implemented Interfaces:
Comparable<Angle>

public class Angle
extends Object
implements Comparable<Angle>

Represents a geometric angle. Instances of Angle are immutable. An angle can be obtained through the factory methods fromDegrees(double) and fromRadians(double).


Field Summary
static String ANGLE_FORMAT_DD
           
static 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
 
Constructor Summary
Angle(Angle angle)
           
 
Method Summary
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 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.
 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(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 fromDMS(int degrees, int minutes, int seconds)
          Obtain an angle from a given number of degrees, minutes and seconds.
static Angle fromDMS(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 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.
 String toDecimalDegreesString(int digits)
          Forms a decimal degrees String representation of this Angle.
 double[] toDMS()
           
 String toDMSString()
          Obtains a String representation of this Angle formated as degrees, minutes and seconds.
 String toFormattedDMSString()
           
 String toString()
          Obtains a String representation of this angle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANGLE_FORMAT_DD

public static final String ANGLE_FORMAT_DD
See Also:
Constant Field Values

ANGLE_FORMAT_DMS

public static final String ANGLE_FORMAT_DMS
See Also:
Constant Field Values

degrees

public final double degrees

MINUTE

public static final Angle MINUTE
Represents an angle of 1 minute


NEG180

public static final Angle NEG180
Represents an angle of negative 180 degrees


NEG360

public static final Angle NEG360
Represents an angle of negative 360 degrees


NEG90

public static final Angle NEG90
Represents a right angle of negative 90 degrees


POS180

public static final Angle POS180
Represents an angle of positive 180 degrees


POS360

public static final Angle POS360
Represents an angle of positive 360 degrees


POS90

public static final Angle POS90
Represents a right angle of positive 90 degrees


radians

public final double radians

SECOND

public static final Angle SECOND
Represents an angle of 1 second


ZERO

public static final Angle ZERO
Represents an angle of zero degrees

Constructor Detail

Angle

public Angle(Angle angle)
Method Detail

acos

public static Angle acos(double cosine)

add

public final Angle add(Angle angle)
Obtains the sum of these two angles. Does not accept a null argument. This method is commutative, so 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.

Parameters:
angle - the angle to add to this one.
Returns:
an angle whose size is the total of this angles and angles size.
Throws:
IllegalArgumentException - if angle is null.

addDegrees

public final Angle addDegrees(double degrees)

addRadians

public final Angle addRadians(double radians)

angularDistanceTo

public Angle angularDistanceTo(Angle angle)
Computes the shortest distance between this and angle, as an angle.

Parameters:
angle - the angle to measure angular distance to.
Returns:
the angular distance between this and value.

asin

public static Angle asin(double sine)

atan

public static Angle atan(double tan)

average

public static Angle average(Angle a,
                            Angle b)
Obtains the average of three angles. The order of parameters does not matter.

Parameters:
a - the first angle.
b - the second angle.
Returns:
the average of a1, a2 and a3
Throws:
IllegalArgumentException - if a or b is null

average

public static Angle average(Angle a,
                            Angle b,
                            Angle c)
Obtains the average of three angles. The order of parameters does not matter.

Parameters:
a - the first angle.
b - the second angle.
c - the third angle.
Returns:
the average of a1, a2 and a3.
Throws:
IllegalArgumentException - if a, b or c is null.

compareTo

public final int compareTo(Angle angle)
Compares this 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.

Specified by:
compareTo in interface Comparable<Angle>
Parameters:
angle - the angle to compare against.
Returns:
-1 if this angle is smaller, 0 if both are equal and +1 if this angle is larger.
Throws:
IllegalArgumentException - if angle is null.

cos

public final double cos()
Obtains the cosine of this angle.

Returns:
the trigonometric cosine of this angle.

cosHalfAngle

public final double cosHalfAngle()

crossesLongitudeBoundary

public static boolean crossesLongitudeBoundary(Angle angleA,
                                               Angle angleB)

divide

public final double divide(Angle angle)
Divides this angle by another angle. This angle remains unchanged, instead the resulting value in degrees is returned.

Parameters:
angle - the angle by which to divide.
Returns:
this angle's degrees divided by angle's degrees.
Throws:
IllegalArgumentException - if angle is null.

divide

public final Angle divide(double divisor)
Divides this angle by divisor. This angle remains unchanged. The result is returned as a new angle. Behaviour is undefined if divisor equals zero.

Parameters:
divisor - the number to be divided by.
Returns:
a new angle equivalent to this angle divided by divisor.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

fromDegrees

public static Angle fromDegrees(double degrees)
Obtains an angle from a specified number of degrees.

Parameters:
degrees - the size in degrees of the angle to be obtained
Returns:
a new angle, whose size in degrees is given by degrees

fromDegreesLatitude

public static Angle fromDegreesLatitude(double degrees)

fromDegreesLongitude

public static Angle fromDegreesLongitude(double degrees)

fromDMS

public static Angle fromDMS(int degrees,
                            int minutes,
                            int seconds)
Obtain an angle from a given number of degrees, minutes and seconds.

Parameters:
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.
Returns:
a new angle whose size in degrees is given by degrees, minutes and seconds.
Throws:
IllegalArgumentException - if minutes or seconds are outside the 0-60 range.

fromDMS

public static Angle fromDMS(String dmsString)
Obtain an angle from a degrees, minute and seconds character string.

eg:

 123 34 42
 -123° 34' 42"
 +45° 12' 30"
 45 12 30 S
 45 12 30 N
 

Parameters:
dmsString - the degrees, minute and second character string.
Returns:
the corresponding angle.
Throws:
IllegalArgumentException - if dmsString is null or not properly formated.

fromRadians

public static Angle fromRadians(double radians)
Obtains an angle from a specified number of radians.

Parameters:
radians - the size in radians of the angle to be obtained.
Returns:
a new angle, whose size in radians is given by radians.

fromRadiansLatitude

public static Angle fromRadiansLatitude(double radians)

fromRadiansLongitude

public static Angle fromRadiansLongitude(double radians)

fromXY

public static Angle fromXY(double x,
                           double y)
Obtains an angle from rectangular coordinates.

Parameters:
x - the abscissa coordinate.
y - the ordinate coordinate.
Returns:
a new angle, whose size is determined from x and y.

getDegrees

public final double getDegrees()
Retrieves the size of this angle in degrees. This method may be faster than first obtaining the radians and then converting to degrees.

Returns:
the size of this angle in degrees.

getRadians

public final double getRadians()
Retrieves the size of this angle in radians. This may be useful for 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.

Returns:
the size of this angle in radians.

getSizeInBytes

public long getSizeInBytes()
Obtains the amount of memory this Angle consumes.

Returns:
the memory footprint of this angle in bytes.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isValidLatitude

public static boolean isValidLatitude(double value)

isValidLongitude

public static boolean isValidLongitude(double value)

max

public static Angle max(Angle a,
                        Angle b)

midAngle

public static Angle midAngle(Angle a1,
                             Angle a2)
Obtains the average of two angles. This method is commutative, so midAngle(m, n) and midAngle(n, m) are equivalent.

Parameters:
a1 - the first angle.
a2 - the second angle.
Returns:
the average of a1 and a2 throws IllegalArgumentException if either angle is null.

min

public static Angle min(Angle a,
                        Angle b)

mix

public static Angle mix(double amount,
                        Angle value1,
                        Angle value2)
Linearly interpolates between two angles.

Parameters:
amount - the interpolant.
value1 - the first angle.
value2 - the second angle.
Returns:
a new angle between value1 and value2.

multiply

public final Angle multiply(double multiplier)
Multiplies this angle by multiplier. This angle remains unchanged. The result is returned as a new angle.

Parameters:
multiplier - a scalar by which this angle is multiplied.
Returns:
a new angle whose size equals this angle's size multiplied by multiplier.

normalizedLatitude

public Angle normalizedLatitude()

normalizedLatitude

public static Angle normalizedLatitude(Angle unnormalizedAngle)

normalizedLongitude

public Angle normalizedLongitude()

normalizedLongitude

public static Angle normalizedLongitude(Angle unnormalizedAngle)

sin

public final double sin()
Obtains the sine of this angle.

Returns:
the trigonometric sine of this angle.

sinHalfAngle

public final double sinHalfAngle()

subtract

public final Angle subtract(Angle angle)
Obtains the difference of these two angles. Does not accept a null argument. This method is not commutative. Neither this angle nor angle is changed, instead the result is returned as a new angle.

Parameters:
angle - the angle to subtract from this angle.
Returns:
a new angle correpsonding to this angle's size minus angle's size.
Throws:
IllegalArgumentException - if angle is null.

subtractDegrees

public final Angle subtractDegrees(double degrees)

subtractRadians

public final Angle subtractRadians(double radians)

tanHalfAngle

public final double tanHalfAngle()
Obtains the tangent of half of this angle.

Returns:
the trigonometric tangent of half of this angle.

toDecimalDegreesString

public final String toDecimalDegreesString(int digits)
Forms a decimal degrees String representation of this Angle.

Parameters:
digits - the number of digits past the decimal point to include in the string.
Returns:
the value of this angle in decimal degrees as a string with the specified number of digits beyond the decimal point. The string is padded with trailing zeros to fill the number of post-decimal point positions requested.

toDMS

public final double[] toDMS()

toDMSString

public final String toDMSString()
Obtains a String representation of this Angle formated as degrees, minutes and seconds.

Returns:
the value of this angle in degrees, minutes, seconds as a string.

toFormattedDMSString

public final String toFormattedDMSString()

toString

public final String toString()
Obtains a String representation of this angle.

Overrides:
toString in class Object
Returns:
the value of this angle in degrees and as a String.

NASA World Wind