uavsim.datatypes
Class Velocity

java.lang.Object
  extended by uavsim.datatypes.Velocity
All Implemented Interfaces:
java.lang.Comparable<Velocity>, I_Unitable<Velocity>

public class Velocity
extends java.lang.Object
implements I_Unitable<Velocity>

Defines a velocity as a speed and direction as a navigational angle. The units are arbitrary as either miles per hour or knots. No internal calculations rely on the units. xxx consider Speed and Groundspeed datatypes

Author:
Dan Tappan [09.10.11]

Field Summary
private  AngleNavigational _direction
          the angle
private  Airspeed _speed
          the speed
 
Constructor Summary
Velocity()
          Creates a velocity object with a default angle and speed of zero.
Velocity(AngleNavigational angle, Airspeed speed)
          Creates a velocity object.
 
Method Summary
 Velocity add_(Velocity velocity)
          Adds another unit to this one.
 int compareTo(Velocity velocity)
           This always returns zero.
 CoordinateCartesianRelative generateDeltas()
          Generates a relative Cartesian coordinate from the angle and speed of this velocity.
 AngleNavigational getDirection()
          Gets the angle.
 Airspeed getSpeed()
          Gets the speed.
 double getValue_()
          Returns the numerical value of this unit.
 boolean hasSpeed()
          Returns whether the velocity has a speed; otherwise, its direction is not meaningful.
 Velocity interpolate(Velocity velocity, Scaler scaler)
          Interpolates between this velocity and another.
 Velocity subtract_(Velocity velocity)
          Subtract another unit from this one.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_direction

private final AngleNavigational _direction
the angle


_speed

private final Airspeed _speed
the speed

Constructor Detail

Velocity

public Velocity()
Creates a velocity object with a default angle and speed of zero.


Velocity

public Velocity(AngleNavigational angle,
                Airspeed speed)
Creates a velocity object.

Parameters:
angle - - the angle
speed - - the speed
Method Detail

add_

public Velocity add_(Velocity velocity)
Adds another unit to this one.

Specified by:
add_ in interface I_Unitable<Velocity>
Parameters:
velocity - - the unit
Returns:
the result as a new unit

compareTo

public int compareTo(Velocity velocity)
This always returns zero.

Specified by:
compareTo in interface java.lang.Comparable<Velocity>

generateDeltas

public CoordinateCartesianRelative generateDeltas()
Generates a relative Cartesian coordinate from the angle and speed of this velocity.

Returns:
the coordinate

getDirection

public AngleNavigational getDirection()
Gets the angle.

Returns:
the angle

getSpeed

public Airspeed getSpeed()
Gets the speed.

Returns:
the speed

getValue_

public double getValue_()
Returns the numerical value of this unit. This maps rounded speed as the whole-number part and rounded direction as the fractional part. Roundoff errors may affect the direction; only its first three digits should be used.

Specified by:
getValue_ in interface I_Unitable<Velocity>
Returns:
the value

hasSpeed

public boolean hasSpeed()
Returns whether the velocity has a speed; otherwise, its direction is not meaningful.

Returns:
the state

interpolate

public Velocity interpolate(Velocity velocity,
                            Scaler scaler)
Interpolates between this velocity and another. For direction, it interpolates over the shortest arc length in a the appropriate direction.

Parameters:
velocity - - the second velocity
scaler - - the scaler between the velocities
Returns:
the interpolated velocity

subtract_

public Velocity subtract_(Velocity velocity)
Subtract another unit from this one.

Specified by:
subtract_ in interface I_Unitable<Velocity>
Parameters:
velocity - - the unit
Returns:
the result as a new unit

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object