public interface UnitConverter
Instances of this class are usually obtained through the Unit.getConverterTo(Unit)
method.
Unit
,
Wikipedia: Conversion of unitsModifier and Type | Method | Description |
---|---|---|
UnitConverter |
concatenate(UnitConverter converter) |
Concatenates this converter with another converter.
|
double |
convert(double value) |
Converts a
double value. |
Number |
convert(Number value) |
Converts a
Number value. |
List<? extends UnitConverter> |
getConversionSteps() |
Returns the steps of fundamental converters making up this converter or
this if the converter is a fundamental converter. |
UnitConverter |
inverse() |
Returns the inverse of this converter.
|
boolean |
isIdentity() |
Indicates if this converter is an identity converter.
|
boolean |
isLinear() |
Indicates whether this converter represents a (one-dimensional) linear transformation, that is
a linear map (wikipedia) from a one-dimensional
vector space (a scalar) to a one-dimensional vector space.
|
boolean isIdentity()
convert(x) == x
).
Note: Identity converters are also always 'linear', see isLinear()
.
true
if this converter is an identity converter.boolean isLinear()
Given such a 'linear' converter 'A', let 'u', 'v' and 'r' be arbitrary numbers, then the following must hold by definition:
A(u + v) == A(u) + A(v)
A(r * u) == r * A(u)
Given a second 'linear' converter 'B', commutativity of composition follows by above definition:
(A o B) (u) == (B o A) (u)
A(B(u)) == B(A(u))
, meaning
for 'A' and 'B' the order of their composition does not matter. Expressed as Java code:
A.concatenate(B).convert(u) == B.concatenate(A).convert(u)
concatenate(UnitConverter)
.true
if this converter represents a linear transformation;
false
otherwise.UnitConverter inverse()
x
is a valid value, then x == inverse().convert(convert(x))
to within the accuracy of
computer arithmetic.Number convert(Number value)
Number
value.value
- the Number
value to convert.Number
value after conversion.double convert(double value)
double
value.value
- the numeric value to convert.double
value after conversion.UnitConverter concatenate(UnitConverter converter)
converter
- the other converter to concatenate with this converter.List<? extends UnitConverter> getConversionSteps()
Returns the steps of fundamental converters making up this converter or this
if the converter is a fundamental converter.
For example, converter1.getConversionSteps()
returns converter1
while
converter1.concatenate(converter2).getConversionSteps()
returns converter1, converter2
.
Copyright © 2014–2019 Jean-Marie Dautelle, Werner Keil, Otavio Santana. All rights reserved.