net.agmodel.physical
Class Speed

java.lang.Object
  |
  +--net.agmodel.physical.AbstractQuantity
        |
        +--net.agmodel.physical.Speed
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public final class Speed
extends AbstractQuantity
implements Comparable

This class represents a distance traveled divided by the time of travel.

See Also:
Length, Duration, Serialized Form

Field Summary
 
Fields inherited from class net.agmodel.physical.AbstractQuantity
AMOUNT_OF_SUBSTANCE, COMPLETE, derivation, DEVOID, DIMENSIONLESS, ELECTRIC_CURRENT, LENGTH, LUMINOUS_INTENSITY, MASS, SPATIALLYINTERPOLATED, TEMPORALLYINTERPOLATED, THERMODYNAMIC_TEMPERATURE, TIME, UNINTERPOLATED
 
Constructor Summary
Speed(Composite c)
          Speed constructor from Composite quantity.
Speed(double value, SpeedUnit unit)
          Speed constructor.
 
Method Summary
 Speed add(Speed x)
          Returns a Speed whose value is (this + x).
 int compareTo(Object o)
          Compares this Speed with the specified Object.
 int compareTo(Speed x)
          Compares this Speed with the specified Speed.
 Speed divide(double coefficient)
          Returns a Speed whose value is (this / coefficient).
 Acceleration divide(Duration d)
          Returns an Acceleration whose value is (this / d).
protected  int getDimensionSI()
          Gets the SI dimension of this Speed.
 double getValue(SpeedUnit unit)
          Gets the speed in the specified unit.
protected  double getValueSI()
          Gets the speed in SI units.
 Speed multiply(double coefficient)
          Returns a Speed whose value is (this * coefficient).
 Length multiply(Duration d)
          Returns a Length whose value is (this * d).
 void setValue(double value, SpeedUnit unit)
          Sets this Speed using the specified unit.
 Speed substract(Speed x)
          Returns a Speed whose value is (this - x).
 
Methods inherited from class net.agmodel.physical.AbstractQuantity
clone, divide, getSymbolSI, isSpatiallyInterpolated, isTemporallyInterpolated, multiply, toComposite, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Speed

public Speed(double value,
             SpeedUnit unit)
Speed constructor.

Parameters:
value - the speed in the specified unit.
unit - the measurement unit being used.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

Speed

public Speed(Composite c)
Speed constructor from Composite quantity.

Parameters:
c - the quantity to convert.
Throws:
UnitDimensionException - composite is not a speed.
See Also:
Composite
Method Detail

getValue

public double getValue(SpeedUnit unit)
Gets the speed in the specified unit.

Parameters:
unit - the measurement unit being used.
Returns:
speed in the specified measurement unit.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

setValue

public void setValue(double value,
                     SpeedUnit unit)
Sets this Speed using the specified unit.

Parameters:
value - the new speed in the specified unit.
unit - the measurement unit being used.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

add

public Speed add(Speed x)
Returns a Speed whose value is (this + x).

Parameters:
x - the Speed to be added.
Returns:
(this + x)

substract

public Speed substract(Speed x)
Returns a Speed whose value is (this - x).

Parameters:
x - the Speed to be substracted.
Returns:
(this - x)

multiply

public Speed multiply(double coefficient)
Returns a Speed whose value is (this * coefficient).

Parameters:
coefficient - the dimensionless multiplier.
Returns:
(this * coefficient)

divide

public Speed divide(double coefficient)
Returns a Speed whose value is (this / coefficient).

Parameters:
coefficient - the dimensionless divisor.
Returns:
(this / coefficient)
Throws:
ArithmeticException - coefficient == 0.0

multiply

public Length multiply(Duration d)
Returns a Length whose value is (this * d).

Parameters:
d - the duration multiplier.
Returns:
(this * d)

divide

public Acceleration divide(Duration d)
Returns an Acceleration whose value is (this / d).

Parameters:
d - the duration divisor.
Returns:
(this / d)

compareTo

public int compareTo(Speed x)
Compares this Speed with the specified Speed. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0), where <op> is one of the six comparison operators.

Parameters:
x - Speed to which this Speed is to be compared.
Returns:
-1, 0 or 1 as this Speed is numerically less than, equal to, or greater than x.

compareTo

public int compareTo(Object o)
Compares this Speed with the specified Object. If the Object is a Speed, this method behaves like compareTo(Speed). Otherwise, it throws a ClassCastException (as Speeds are comparable only to other Speeds).

Specified by:
compareTo in interface Comparable
Parameters:
o - Object to which this Speed is to be compared.
Returns:
a negative number, zero, or a positive number as this Speed is numerically less than, equal to, or greater than o, which must be a Speed.
Throws:
ClassCastException - o is not a Speed.
See Also:
compareTo(Speed), Comparable

getValueSI

protected double getValueSI()
Gets the speed in SI units.

Specified by:
getValueSI in class AbstractQuantity
Returns:
speed in SI units.

getDimensionSI

protected int getDimensionSI()
Gets the SI dimension of this Speed.

Specified by:
getDimensionSI in class AbstractQuantity
Returns:
LENGTH - TIME