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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2019-01-18 00:35:01 +0100 (Fri, 18 Jan 2019) $, @version $Revision: 324 $, 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; double valueunit
- LengthUnit; unit for the double valuepublic Length(Length value)
value
- Length; Scalar from which to construct this instancepublic final Length instantiateRel(double value, LengthUnit unit)
instantiateRel
in class AbstractDoubleScalarRel<LengthUnit,Length>
value
- double; the double valueunit
- U; the unitpublic final Position instantiateAbs(double value, PositionUnit unit)
value
- double; the double valueunit
- PositionUnit; the unitpublic static final Length createSI(double value)
value
- double; double value in SI unitspublic static Length interpolate(Length zero, Length one, double ratio)
zero
- Length; the low valueone
- Length; the high valueratio
- double; the ratio between 0 and 1, inclusivepublic final Position plus(Position v)
v
- Position; the value to addpublic static Length max(Length r1, Length r2)
r1
- Length; the first scalarr2
- Length; the second scalarpublic static Length max(Length r1, Length r2, Length... rn)
r1
- Length; the first scalarr2
- Length; the second scalarrn
- Length...; the other scalarspublic static Length min(Length r1, Length r2)
r1
- Length; the first scalarr2
- Length; the second scalarpublic static Length min(Length r1, Length r2, Length... rn)
r1
- Length; the first scalarr2
- Length; the second scalarrn
- Length...; the other scalarspublic final Dimensionless divideBy(Length v)
v
- Length; Length scalarpublic final Area multiplyBy(Length v)
v
- Length; Length scalarpublic final Area divideBy(LinearDensity v)
v
- LinearDensity; Length scalarpublic final LinearDensity divideBy(Area v)
v
- Area; Length scalarpublic final Volume multiplyBy(Area v)
v
- Area; Length scalarpublic final Energy multiplyBy(Force v)
v
- Force; Length scalarpublic final Speed multiplyBy(Frequency v)
v
- Frequency; Length scalarpublic final Speed divideBy(Duration v)
v
- Duration; Length scalarpublic final Duration divideBy(Speed v)
v
- Speed; Length scalarpublic final Money multiplyBy(MoneyPerLength v)
v
- MoneyPerLength; Length scalarCopyright © 2015–2019 Delft University of Technology. All rights reserved.