NASA World Wind

gov.nasa.worldwind.geom
Class Angle

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

public class Angle
extends java.lang.Object
implements java.lang.Comparable<Angle>

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


Field Summary
 double degrees
           
static Angle NEG180
          Represents an angle of negative 180 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 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 angle for order.
 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 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 Angle midAngle(Angle a1, Angle a2)
          Obtains the average of two Angles.
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.
 java.lang.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

degrees

public final double degrees

NEG180

public static final Angle NEG180
Represents an angle of negative 180 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

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:
java.lang.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:
java.lang.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:
java.lang.IllegalArgumentException - if a, b or c is null

compareTo

public final int compareTo(Angle angle)
Compares this Angle with angle for order. 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 java.lang.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:
java.lang.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:
java.lang.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(java.lang.Object o)
Overrides:
equals in class java.lang.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)

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 java.lang.Object

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

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:
java.lang.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

toString

public final java.lang.String toString()
Obtains a String representation of this Angle.

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

NASA World Wind