uavsim.datatypes
Class A_Angle<_ANGLETYPE_ extends A_Angle<?>>

java.lang.Object
  extended by uavsim.datatypes.A_Angle<_ANGLETYPE_>
Type Parameters:
_ANGLETYPE_ - - the type of angle: currently mathematical or navigational
All Implemented Interfaces:
java.lang.Comparable<_ANGLETYPE_>, I_Unitable<_ANGLETYPE_>
Direct Known Subclasses:
AngleMathematical, AngleNavigational

public abstract class A_Angle<_ANGLETYPE_ extends A_Angle<?>>
extends java.lang.Object
implements I_Unitable<_ANGLETYPE_>

Defines the shared aspects of an angle.

Author:
Dan Tappan [23.06.11]

Field Summary
private  double _angleDegrees
          the angle in degrees; it should always be normalized
private static java.text.DecimalFormat ANGLE_FORMATTER
          the format for three-digit angles
 
Constructor Summary
A_Angle(double angle)
          Creates an abstract angle object.
 
Method Summary
 int compareTo(_ANGLETYPE_ angle)
          
 java.lang.String formatString()
          Formats the angle string as [zzz???].
 double getValue_()
          Returns the numerical value of this unit.
 double getValueAffineRadians()
          Gets the affine radians value of the angle, defined as -radians(degrees - 90).
 java.lang.String getValueFormatted()
          Formats the angle as three digits.
 int getValueInt()
          Rounds the angle to the nearest integer.
 double getValueRadians()
          Gets the angle in radians.
abstract  _ANGLETYPE_ interpolate(_ANGLETYPE_ angle, Scaler scaler)
          Interpolates between this angle and another.
abstract  _ANGLETYPE_ interpolate(_ANGLETYPE_ angle, Scaler scaler, boolean isOverShortestPath)
          Interpolates between this angle and another.
abstract  boolean isShortestPathClockwise(_ANGLETYPE_ angle)
          Determines whether the shortest direction between this angle and another is clockwise.
static double normalizeAngle(double angleDegrees)
          Normalizes an angle to the interval [0,360).
protected  double offset(double angle)
          Offsets this angle by another (by addition).
protected  double scale(double fraction)
          Scales this angle by a percent of a circle.
protected  double scale(Scaler scaler)
          Scales this angle by a percent of a circle.
private  void setAngle(double angleDegrees)
          Sets the angle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uavsim.datatypes.I_Unitable
add_, subtract_
 

Field Detail

_angleDegrees

private double _angleDegrees
the angle in degrees; it should always be normalized


ANGLE_FORMATTER

private static final java.text.DecimalFormat ANGLE_FORMATTER
the format for three-digit angles

Constructor Detail

A_Angle

public A_Angle(double angle)
Creates an abstract angle object.

Parameters:
angle - - the angle in degrees
Method Detail

compareTo

public int compareTo(_ANGLETYPE_ angle)

Specified by:
compareTo in interface java.lang.Comparable<_ANGLETYPE_ extends A_Angle<?>>

formatString

public java.lang.String formatString()
Formats the angle string as [zzz???].

Returns:
the string

getValue_

public double getValue_()
Returns the numerical value of this unit.

Specified by:
getValue_ in interface I_Unitable<_ANGLETYPE_ extends A_Angle<?>>
Returns:
the value

getValueAffineRadians

public double getValueAffineRadians()
Gets the affine radians value of the angle, defined as -radians(degrees - 90).

Returns:
the value

getValueFormatted

public java.lang.String getValueFormatted()
Formats the angle as three digits.

Returns:
the angle

getValueInt

public int getValueInt()
Rounds the angle to the nearest integer.

Returns:
the result

getValueRadians

public double getValueRadians()
Gets the angle in radians.

Returns:
the angle

interpolate

public abstract _ANGLETYPE_ interpolate(_ANGLETYPE_ angle,
                                        Scaler scaler)
Interpolates between this angle and another.

Parameters:
angle - - the ending angle
scaler - - the scaler for the interpolated point
Returns:
the angle

interpolate

public abstract _ANGLETYPE_ interpolate(_ANGLETYPE_ angle,
                                        Scaler scaler,
                                        boolean isOverShortestPath)
Interpolates between this angle and another.

Parameters:
angle - - the ending angle
scaler - - the scaler for the interpolated point
isOverShortestPath - - whether to interpolate over the shortest or longest arc length in the appropriate direction
Returns:
the angle

isShortestPathClockwise

public abstract boolean isShortestPathClockwise(_ANGLETYPE_ angle)
Determines whether the shortest direction between this angle and another is clockwise.

Parameters:
angle - - the other angle
Returns:
the state

normalizeAngle

public static double normalizeAngle(double angleDegrees)
Normalizes an angle to the interval [0,360).

Parameters:
angleDegrees - - the angle in degrees
Returns:
the normalized angle

offset

protected double offset(double angle)
Offsets this angle by another (by addition). It does not normalize the result.

Parameters:
angle - - the offset angle
Returns:
the result

scale

protected double scale(double fraction)
Scales this angle by a percent of a circle. zzz

Parameters:
fraction - - the percent on the interval [0,1]
Returns:
the result

scale

protected double scale(Scaler scaler)
Scales this angle by a percent of a circle. zzz normalizes

Parameters:
scaler - - the scaler
Returns:
the result

setAngle

private void setAngle(double angleDegrees)
Sets the angle.

Parameters:
angleDegrees - - the angle in degrees