Package org.djunits.unit.scale
Class LinearScale
java.lang.Object
org.djunits.unit.scale.LinearScale
- All Implemented Interfaces:
Serializable,Scale
- Direct Known Subclasses:
IdentityScale
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).
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-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLinearScale(double scaleFactorToBaseUnit) Construct a Scale for linear transformations.LinearScale(double numerator, double denominator) Construct a Scale for linear transformations, with a numerator and denominator. -
Method Summary
Modifier and TypeMethodDescriptionbooleandoublefromBaseValue(double value) Convert a value from a base (SI) value to a value in the unit that uses this scale.final doubleRetrieve the factor for conversion to the standard unit.inthashCode()booleanReturn whether a scale is a 'standard' scale.doubletoBaseValue(double value) Convert a value expressed in this unit to its base (SI) value.toString()
-
Constructor Details
-
LinearScale
public LinearScale(double scaleFactorToBaseUnit) Construct a Scale for linear transformations. To transform, e.g., a minute to a second, a scale factor of 60 is used.- Parameters:
scaleFactorToBaseUnit- the conversion factor by which this number has to be multiplied to convert it to the base (e.g., SI) unit.
-
LinearScale
public LinearScale(double numerator, double denominator) Construct a Scale for linear transformations, with a numerator and denominator. To transform, e.g., m/s to km/h, a numerator of 1000 (a km is 1000 m) and a denominator of 3600 (an hour is 3600 seconds) is used.- Parameters:
numerator- the factor by which this number has to be multiplied to convert it to the base (e.g., SI) unit.denominator- the factor by which this number has to be divided to convert it to the base (e.g., SI) unit.
-
-
Method Details
-
toBaseValue
public double toBaseValue(double value) Description copied from interface:ScaleConvert a value expressed in this unit to its base (SI) value.- Specified by:
toBaseValuein interfaceScale- Parameters:
value- the value expressed in this unit- Returns:
- the value converted to its SI value
-
fromBaseValue
public double fromBaseValue(double value) Description copied from interface:ScaleConvert a value from a base (SI) value to a value in the unit that uses this scale.- Specified by:
fromBaseValuein interfaceScale- Parameters:
value- the value to convert- Returns:
- the corresponding value in the given unit
-
getScaleFactorToBaseUnit
public final double getScaleFactorToBaseUnit()Retrieve the factor for conversion to the standard unit.- Returns:
- the factor for conversion to the standard unit
-
isBaseScale
public boolean isBaseScale()Description copied from interface:ScaleReturn whether a scale is a 'standard' scale. 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:
isBaseScalein interfaceScale- Returns:
- whether the scale is a 'standard' scale
-
hashCode
public int hashCode() -
equals
-
toString
-