net.agmodel.physical
Class Length

java.lang.Object
  extended bynet.agmodel.physical.AbstractQuantity
      extended bynet.agmodel.physical.Length
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public final class Length
extends AbstractQuantity
implements Comparable

This class represents the extent of something along its greatest dimension or the extent of space between two objects or places.

Version:
1.1, 22 March 1999
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.agmodel.physical.AbstractQuantity
COMPLETE, DEVOID, SPATIALLYINTERPOLATED, TEMPORALLYINTERPOLATED, UNINTERPOLATED
 
Constructor Summary
Length(Composite c)
          Length constructor from Composite quantity.
Length(double value, LengthUnit unit)
          Length constructor.
Length(Length radius, Angle theta)
          Length constructor from a Length and an Angle (arc of a circle).
 
Method Summary
 Length add(Length x)
          Returns a Length whose value is (this + x).
 int compareTo(Length x)
          Compares this Length with the specified Length.
 int compareTo(Object o)
          Compares this Length with the specified Object.
 Length divide(double coefficient)
          Returns a Length whose value is (this / coefficient).
 Speed divide(Duration d)
          Returns a Speed whose value is (this / d).
 double getValue(LengthUnit unit)
          Gets the length in the specified unit.
static Length magnitude(Length x, Length y)
          Converts rectangular coordinates (xy) to polar (rho, theta).
 Volume multiply(Area x)
          Returns a Volume whose value is (this * x).
 Length multiply(double coefficient)
          Returns a Length whose value is (this * coefficient).
 Area multiply(Length x)
          Returns an Area whose value is (this * x).
 void setValue(double value, LengthUnit unit)
          Sets this Length using the specified unit.
 Length substract(Length x)
          Returns a Length whose value is (this - x).
 
Methods inherited from class net.agmodel.physical.AbstractQuantity
clone, divide, isSpatiallyInterpolated, isTemporallyInterpolated, multiply, toComposite, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Length

public Length(double value,
              LengthUnit unit)
Length constructor.

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

Length

public Length(Length radius,
              Angle theta)
Length constructor from a Length and an Angle (arc of a circle). It returns the length of the arc defined from the specified circle radius and central angle.

Parameters:
radius - the circle radius.
theta - the central angle.

Length

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

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

getValue

public double getValue(LengthUnit unit)
Gets the length in the specified unit.

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

setValue

public void setValue(double value,
                     LengthUnit unit)
Sets this Length using the specified unit.

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

add

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

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

substract

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

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

multiply

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

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

multiply

public Area multiply(Length x)
Returns an Area whose value is (this * x).

Parameters:
x - the Length multiplier.
Returns:
(this * x)

multiply

public Volume multiply(Area x)
Returns a Volume whose value is (this * x).

Parameters:
x - the Area multiplier.
Returns:
(this * x)

divide

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

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

magnitude

public static Length magnitude(Length x,
                               Length y)
Converts rectangular coordinates (xy) to polar (rho, theta). This method computes the magnitude rho of the polar vector.

Parameters:
x - x coordinate value.
y - y coordinate value.
Returns:
the rho component of the point (rhotheta) in polar coordinates that corresponds to the point (xy) in Cartesian coordinates.
See Also:
Angle.atan2(Length, Length)

divide

public Speed divide(Duration d)
Returns a Speed whose value is (this / d).

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

compareTo

public int compareTo(Length x)
Compares this Length with the specified Length. 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 - Length to which this Length is to be compared.
Returns:
-1, 0 or 1 as this Length is numerically less than, equal to, or greater than x.

compareTo

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

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


Copyright (C) NARC 2001 All Rights Reserved.