Jeospace API

org.jeospace.measure.angle
Class DecimalAngle

java.lang.Object
  extended byorg.jeospace.measure.angle.DecimalAngle
All Implemented Interfaces:
Angle, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
Latitude, Longitude

public class DecimalAngle
extends java.lang.Object
implements Angle, java.lang.Cloneable

DecimalAngle provides a concrete implementation of Angle which is designed for high performance usage in conjunction with java.lang.Math trigonometric methods - or other functions which require double precision floating point representations of angular measurements.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Angle, AngleNorm, AngleSign, DecimalAngleUnit, Latitude, Longitude, SexagesimalAngle, SexagesimalAngleType, SexagesimalAngleUnit

Field Summary
protected  double angle
          The value of this DecimalAngle object.
 
Constructor Summary
DecimalAngle()
          Construct a DecimalAngle initialized to a value of 0.
DecimalAngle(Angle ang)
          Construct a DecimalAngle initialized to the specified value.
DecimalAngle(DecimalAngleUnit units, double value)
          Construct a DecimalAngle initialized to the value and units specified.
DecimalAngle(SexagesimalAngleType type, AngleSign sign, double unitsValue)
          Construct a DecimalAngle initialized to the value and units specified.
DecimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, double minutes)
          Construct a DecimalAngle initialized to the value and units specified.
DecimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, double seconds)
          Construct a DecimalAngle initialized to the value and units specified.
DecimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, int seconds, int microseconds)
          Construct a DecimalAngle initialized to the value and units specified.
 
Method Summary
 void add(Angle ang)
          Add to this DecimalAngle the passed Angle.
 void add(DecimalAngleUnit units, double value)
          Add to this DecimalAngle the double value in the specified DecimalAngleUnits.
 void add(SexagesimalAngleUnit units, int value)
          Add to this DecimalAngle the value in the specified SexagesimalAngleUnits.
 void changeSign()
          Change the sign of this DecimalAngle.
 void clear()
          Set the value of this DecimalAngle to 0.
 java.lang.Object clone()
          Return a copy of this DecimalAngle object.
 int compareTo(Angle that)
          Compare this object with the argument for order.
 int compareTo(java.lang.Object obj)
          Compare this object with the argument for order.
 boolean equals(java.lang.Object obj)
          Compare two Angles for equality.
 double get(DecimalAngleUnit units)
          Return the double value of this DecimalAngle in the specified DecimalAngleUnits.
 AngleSign getSign()
          Get the AngleSign of this DecimalAngle.
 long getValueInMicroseconds(SexagesimalAngleType type)
          Return the long value of this DecimalAngle in units of microseconds of the specified SexagesimalAngleType.
 int hashCode()
          Return the hashcode
 void normalize(AngleNorm option)
          Normalize the value of this DecimalAngle as specified by the option field.
static double normalizeDegrees(double degrees)
          Normalize and return the double degree value.
static double normalizeDegreesNegative(double degrees)
          Normalize the double degree value to an equivalent negative value and return.
static double normalizeDegreesPositive(double degrees)
          Normalize the double degree value to an equivalent positive value and return.
static double normalizeRadians(double radians)
          Normalize and return the double radian value.
static double normalizeRadiansNegative(double radians)
          Normalize the double radian value to an equivalent negative value and return.
static double normalizeRadiansPositive(double radians)
          Normalize the double radian value to an equivalent positive value and return.
 void set(Angle ang)
          Set this DecimalAngle to the specified value.
 void set(DecimalAngleUnit units, double value)
          Set the value of this DecimalAngle to the specified DecimalAngleUnits value.
 void set(SexagesimalAngleType type, AngleSign sign, double unitsValue)
          Set this DecimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, double minutes)
          Set this DecimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, double seconds)
          Set this DecimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, int seconds, int microseconds)
          Set this DecimalAngle to the specified value in the SexagesimalAngleType.
 void setValueInMicroseconds(SexagesimalAngleType type, long value)
          Set this DecimalAngle to the specified value of microseconds of the SexagesimalAngleType.
 void subtract(Angle ang)
          Subtract from this DecimalAngle the passed Angle.
 java.lang.String toString()
          Return a string representation of this DecimalAngle in decimal degrees.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

angle

protected double angle
The value of this DecimalAngle object.

Constructor Detail

DecimalAngle

public DecimalAngle()
Construct a DecimalAngle initialized to a value of 0.


DecimalAngle

public DecimalAngle(Angle ang)
Construct a DecimalAngle initialized to the specified value.

Parameters:
ang - the Angle object to duplicate.

DecimalAngle

public DecimalAngle(DecimalAngleUnit units,
                    double value)
Construct a DecimalAngle initialized to the value and units specified.

Parameters:
units - the DecimalAngleUnits of value being input.
value - the input value

DecimalAngle

public DecimalAngle(SexagesimalAngleType type,
                    AngleSign sign,
                    double unitsValue)
Construct a DecimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the double value of the primary units of the SexagesimalAngleType.

DecimalAngle

public DecimalAngle(SexagesimalAngleType type,
                    AngleSign sign,
                    int unitsValue,
                    double minutes)
Construct a DecimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the double value of the minutes sub-unit of the SexagesimalAngleType.

DecimalAngle

public DecimalAngle(SexagesimalAngleType type,
                    AngleSign sign,
                    int unitsValue,
                    int minutes,
                    double seconds)
Construct a DecimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the double value of the seconds sub-unit of the SexagesimalAngleType.

DecimalAngle

public DecimalAngle(SexagesimalAngleType type,
                    AngleSign sign,
                    int unitsValue,
                    int minutes,
                    int seconds,
                    int microseconds)
Construct a DecimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the integer value of the seconds sub-unit of the SexagesimalAngleType.
microseconds - the integer value of the microseconds sub-unit of the SexagesimalAngleType.
Method Detail

set

public void set(Angle ang)
Set this DecimalAngle to the specified value.

Specified by:
set in interface Angle
Parameters:
ang - the Angle object to duplicate.

clear

public void clear()
Set the value of this DecimalAngle to 0.

Specified by:
clear in interface Angle

changeSign

public void changeSign()
Change the sign of this DecimalAngle.

Specified by:
changeSign in interface Angle

getSign

public AngleSign getSign()
Get the AngleSign of this DecimalAngle.

Specified by:
getSign in interface Angle
Returns:
the sign of the value of the angle. An angle with a value zero will return AngleSign.POSITIVE by default.

add

public void add(Angle ang)
Add to this DecimalAngle the passed Angle.

Specified by:
add in interface Angle
Parameters:
ang - an Angle.

subtract

public void subtract(Angle ang)
Subtract from this DecimalAngle the passed Angle.

Specified by:
subtract in interface Angle
Parameters:
ang - an Angle.

normalize

public void normalize(AngleNorm option)
Normalize the value of this DecimalAngle as specified by the option field.

Specified by:
normalize in interface Angle
Parameters:
option - the AngleNorm identifier

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


set

public void set(DecimalAngleUnit units,
                double value)
Set the value of this DecimalAngle to the specified DecimalAngleUnits value.

Specified by:
set in interface Angle
Parameters:
units - the DecimalAngleUnits.
value - the double value.

get

public double get(DecimalAngleUnit units)
Return the double value of this DecimalAngle in the specified DecimalAngleUnits.

Specified by:
get in interface Angle
Parameters:
units - the DecimalAngleUnits.
Returns:
the double value of this Angle.

add

public void add(DecimalAngleUnit units,
                double value)
Add to this DecimalAngle the double value in the specified DecimalAngleUnits.

Specified by:
add in interface Angle
Parameters:
units - the DecimalAngleUnits.
value - the double value.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                double unitsValue)
Set this DecimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the double value of the primary units of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                double minutes)
Set this DecimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the double value of the minutes sub-unit of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                int minutes,
                double seconds)
Set this DecimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the double value of the seconds sub-unit of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                int minutes,
                int seconds,
                int microseconds)
Set this DecimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the integer value of the seconds sub-unit of the SexagesimalAngleType.
microseconds - the integer value of the microseconds sub-unit of the SexagesimalAngleType.

setValueInMicroseconds

public void setValueInMicroseconds(SexagesimalAngleType type,
                                   long value)
Set this DecimalAngle to the specified value of microseconds of the SexagesimalAngleType. (i.e. either in microseconds of of degree or microseconds of hour)

Specified by:
setValueInMicroseconds in interface Angle
Parameters:
type - the SexagesimalAngleType.
value - the long value in microseconds to set for this Angle.

getValueInMicroseconds

public long getValueInMicroseconds(SexagesimalAngleType type)
Return the long value of this DecimalAngle in units of microseconds of the specified SexagesimalAngleType. (i.e. either in microseconds of of degree or microseconds of hour)

Specified by:
getValueInMicroseconds in interface Angle
Parameters:
type - the SexagesimalAngleType.
Returns:
the long value of this Angle in microseconds.

add

public void add(SexagesimalAngleUnit units,
                int value)
Add to this DecimalAngle the value in the specified SexagesimalAngleUnits.

Specified by:
add in interface Angle
Parameters:
units - the SexagesimalAngleUnits.
value - the integer value.

normalizeDegrees

public static final double normalizeDegrees(double degrees)
Normalize and return the double degree value. This will produce a value that is less than a full revolution ( 360 degrees ) and preserve the direction of rotation.

Parameters:
degrees - the double degrees value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


normalizeDegreesPositive

public static final double normalizeDegreesPositive(double degrees)
Normalize the double degree value to an equivalent positive value and return. This will produce a value that is less than a full revolution ( 360 degrees ) but will not preserve the direction of rotation.

Parameters:
degrees - the double degrees value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


normalizeDegreesNegative

public static final double normalizeDegreesNegative(double degrees)
Normalize the double degree value to an equivalent negative value and return. This will produce a value that is less than a full revolution ( -360 degrees ) but will not preserve the direction of rotation.

Parameters:
degrees - the double degrees value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


normalizeRadians

public static final double normalizeRadians(double radians)
Normalize and return the double radian value. This will produce a value that is less than a full revolution ( 2*Math.PI radians ) and preserve the direction of rotation.

Parameters:
radians - the double degrees value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


normalizeRadiansPositive

public static final double normalizeRadiansPositive(double radians)
Normalize the double radian value to an equivalent positive value and return. This will produce a value that is less than a full revolution ( 360 degrees, 2*Math.PI radians ) but will not preserve the direction of rotation.

Parameters:
radians - the double radian value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


normalizeRadiansNegative

public static final double normalizeRadiansNegative(double radians)
Normalize the double radian value to an equivalent negative value and return. This will produce a value that is less than a full revolution ( -2*Math.PI radians ) but will not preserve the direction of rotation.

Parameters:
radians - the double radians value

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


clone

public java.lang.Object clone()
Return a copy of this DecimalAngle object. Overrides Cloneable.

Returns:
a copy of this DecimalAngle object.

hashCode

public int hashCode()
Return the hashcode

Returns:
the hash code value for this object

equals

public boolean equals(java.lang.Object obj)
Compare two Angles for equality. The result is true if and only if the argument object is not null, is an Angle object ( including classes implementing Angle ) and represents an angle of the same sign and magnitude as this Angle.

Parameters:
obj - the object to compare with
Returns:
true if the Angles are the same; false otherwise.

toString

public java.lang.String toString()
Return a string representation of this DecimalAngle in decimal degrees.

Returns:
a string representation of this DecimalAngle

compareTo

public int compareTo(Angle that)
Compare this object with the argument for order.

Specified by:
compareTo in interface Angle
Parameters:
that - the Angle to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(java.lang.Object obj)
Compare this object with the argument for order.

Specified by:
compareTo in interface Angle
Parameters:
obj - the Object to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the argument is not an Angle.

Jeospace API

Copyright © 2006 - jeospace.org