Class 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-2023 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:
    Serialized Form
    • Constructor Detail

      • LinearScale

        public LinearScale​(double conversionFactorToStandardUnit)
        Construct a Scale for linear transformations.
        Parameters:
        conversionFactorToStandardUnit - double; the conversion factor by which this number has to be multiplied to convert it to the standard (e.g., SI) unit.
    • Method Detail

      • toStandardUnit

        public double toStandardUnit​(double value)
        Convert a value to an SI value using this scale.
        Specified by:
        toStandardUnit in interface Scale
        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 interface Scale
        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 interface Scale
        Returns:
        boolean; whether the scale is a 'standard' scale that would belong to an SI unit.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object