Package org.djunits.unit.scale
Class LinearScale
- java.lang.Object
-
- org.djunits.unit.scale.LinearScale
-
- All Implemented Interfaces:
Serializable
,Scale
- Direct Known Subclasses:
IdentityScale
,OffsetLinearScale
public class LinearScale extends Object implements Scale
A Scale for linear transformations not involving a zero-offset, e.g. for Length, Time, Area.
A linear scale is a scale that is linearly relates a unit to the underlying SI standard unit. E.g. Mile is linearly related to meter (the SI unit for length) and the conversion is zero-based (0 miles equals 0 meter). Unlike temperature in degrees Celsius which is not linearly related to the Kelvin (the SI unit for temperature) because the conversion is not zero-based (0°C is 273.15K).Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LinearScale(double conversionFactorToStandardUnit)
Construct a Scale for linear transformations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
double
fromStandardUnit(double value)
Convert a value from an SI value to a value in the unit that uses this scale.double
getConversionFactorToStandardUnit()
Retrieve the factor for conversion to the standard unit.int
hashCode()
boolean
isBaseSIScale()
Return whether a scale is a 'standard' scale that would belong to an SI unit.double
toStandardUnit(double value)
Convert a value to an SI value using this scale.String
toString()
-
-
-
Method Detail
-
toStandardUnit
public double toStandardUnit(double value)
Convert a value to an SI value using this scale.- Specified by:
toStandardUnit
in interfaceScale
- Parameters:
value
- double; the value to convert- Returns:
- the corresponding SI value
-
fromStandardUnit
public double fromStandardUnit(double value)
Convert a value from an SI value to a value in the unit that uses this scale.- Specified by:
fromStandardUnit
in interfaceScale
- Parameters:
value
- double; the value to convert- Returns:
- the corresponding value in the given unit
-
getConversionFactorToStandardUnit
public final double getConversionFactorToStandardUnit()
Retrieve the factor for conversion to the standard unit.- Returns:
- double; the factor for conversion to the standard unit
-
isBaseSIScale
public boolean isBaseSIScale()
Return whether a scale is a 'standard' scale that would belong to an SI unit. For a linear scale, any scale with conversion factor 1 would be considered standard. For an offset scale, it would be considered standard if the offset is 0 and the conversion factor is 1.- Specified by:
isBaseSIScale
in interfaceScale
- Returns:
- boolean; whether the scale is a 'standard' scale that would belong to an SI unit.
-
-