public class Length extends AbstractDoubleScalarRel<LengthUnit,Length>
DoubleScalar<LengthUnit> value = new DoubleScalar<LengthUnit>(100.0, LengthUnit.SI);we can now write:
Length value = new Length(100.0, LengthUnit.SI);The compiler will automatically recognize which units belong to which quantity, and whether the quantity type and the unit used are compatible.
Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, by $Author: averbraeck $,
initial version Sep 1, 2015
Modifier and Type | Field and Description |
---|---|
static Length |
NaN
constant with value NaN.
|
static Length |
NEG_MAXVALUE
constant with value -MAX_VALUE.
|
static Length |
NEGATIVE_INFINITY
constant with value NEGATIVE_INFINITY.
|
static Length |
POS_MAXVALUE
constant with value MAX_VALUE.
|
static Length |
POSITIVE_INFINITY
constant with value POSITIVE_INFINITY.
|
static Length |
ZERO
constant with value zero.
|
si
Constructor and Description |
---|
Length(double value,
LengthUnit unit)
Construct Length scalar.
|
Length(Length value)
Construct Length scalar.
|
Modifier and Type | Method and Description |
---|---|
static Length |
createSI(double value)
Construct Length scalar.
|
LinearDensity |
divideBy(Area v)
Calculate the division of Length and Area, which results in a LinearDensity scalar.
|
Speed |
divideBy(Duration v)
Calculate the division of Length and Duration, which results in a Speed scalar.
|
Dimensionless |
divideBy(Length v)
Calculate the division of Length and Length, which results in a Dimensionless scalar.
|
Area |
divideBy(LinearDensity v)
Calculate the division of Length and LinearDensity, which results in a Area scalar.
|
Duration |
divideBy(Speed v)
Calculate the division of Length and Speed, which results in a Duration scalar.
|
Position |
instantiateAbs(double value,
PositionUnit unit)
Construct a new Absolute Immutable DoubleScalar of the right type.
|
Length |
instantiateRel(double value,
LengthUnit unit)
Construct a new Relative Immutable DoubleScalar of the right type.
|
static Length |
interpolate(Length zero,
Length one,
double ratio)
Interpolate between two values.
|
static Length |
max(Length r1,
Length r2)
Return the maximum value of two relative scalars.
|
static Length |
max(Length r1,
Length r2,
Length... rn)
Return the maximum value of more than two relative scalars.
|
static Length |
min(Length r1,
Length r2)
Return the minimum value of two relative scalars.
|
static Length |
min(Length r1,
Length r2,
Length... rn)
Return the minimum value of more than two relative scalars.
|
Volume |
multiplyBy(Area v)
Calculate the multiplication of Length and Area, which results in a Volume scalar.
|
Energy |
multiplyBy(Force v)
Calculate the multiplication of Length and Force, which results in a Energy scalar.
|
Speed |
multiplyBy(Frequency v)
Calculate the multiplication of Length and Frequency, which results in a Speed scalar.
|
Area |
multiplyBy(Length v)
Calculate the multiplication of Length and Length, which results in a Area scalar.
|
Money |
multiplyBy(MoneyPerLength v)
Calculate the multiplication of Length and MoneyPerLength, which results in a Money scalar.
|
Position |
plus(Position v)
Relative scalar plus Absolute scalar = Absolute scalar.
|
abs, ceil, divideBy, floor, minus, multiplyBy, neg, plus, rint, round
compareTo, doubleValue, eq, eq0, equals, floatValue, ge, ge0, getInUnit, getInUnit, getSI, gt, gt0, hashCode, intValue, le, le0, longValue, lt, lt0, ne, ne0, toString, toString, toString, toString
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit
byteValue, shortValue
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
DIV, MULT, POW
public static final Length ZERO
public static final Length NaN
public static final Length POSITIVE_INFINITY
public static final Length NEGATIVE_INFINITY
public static final Length POS_MAXVALUE
public static final Length NEG_MAXVALUE
public Length(double value, LengthUnit unit)
value
- double valueunit
- unit for the double valuepublic Length(Length value)
value
- Scalar from which to construct this instancepublic final Length instantiateRel(double value, LengthUnit unit)
instantiateRel
in class AbstractDoubleScalarRel<LengthUnit,Length>
value
- the double valueunit
- the unitpublic final Position instantiateAbs(double value, PositionUnit unit)
value
- the double valueunit
- the unitpublic static final Length createSI(double value)
value
- double value in SI unitspublic static Length interpolate(Length zero, Length one, double ratio)
zero
- the low valueone
- the high valueratio
- the ratio between 0 and 1, inclusivepublic final Position plus(Position v)
v
- the value to addpublic static Length max(Length r1, Length r2)
r1
- the first scalarr2
- the second scalarpublic static Length max(Length r1, Length r2, Length... rn)
r1
- the first scalarr2
- the second scalarrn
- the other scalarspublic static Length min(Length r1, Length r2)
r1
- the first scalarr2
- the second scalarpublic static Length min(Length r1, Length r2, Length... rn)
r1
- the first scalarr2
- the second scalarrn
- the other scalarspublic final Dimensionless divideBy(Length v)
v
- Length scalarpublic final Area multiplyBy(Length v)
v
- Length scalarpublic final Area divideBy(LinearDensity v)
v
- Length scalarpublic final LinearDensity divideBy(Area v)
v
- Length scalarpublic final Volume multiplyBy(Area v)
v
- Length scalarpublic final Energy multiplyBy(Force v)
v
- Length scalarpublic final Speed multiplyBy(Frequency v)
v
- Length scalarpublic final Speed divideBy(Duration v)
v
- Length scalarpublic final Duration divideBy(Speed v)
v
- Length scalarpublic final Money multiplyBy(MoneyPerLength v)
v
- Length scalarCopyright © 2015–2018 Delft University of Technology. All rights reserved.