Class Length.Unit

All Implemented Interfaces:
UnitInterface<Length.Unit,Length>
Enclosing class:
Length

public static class Length.Unit extends AbstractUnit<Length.Unit,Length>
Length.Unit encodes the length unit.

Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.

Author:
Alexander Verbraeck
  • Field Details

    • CONST_FT

      public static final double CONST_FT
      Constant for the foot.
      See Also:
    • CONST_YD

      public static final double CONST_YD
      Constant for the yard.
      See Also:
    • CONST_IN

      public static final double CONST_IN
      Constant for the inch.
      See Also:
    • CONST_MI

      public static final double CONST_MI
      Constant for the mile.
      See Also:
    • CONST_NM

      public static final double CONST_NM
      Constant for the nautical mile.
      See Also:
    • CONST_AU

      public static final double CONST_AU
      Constant for the Astronomical Unit = 149,597,870,700 m.
      See Also:
    • CONST_LY

      public static final double CONST_LY
      Constant for the lightyear = 9,460,730,472,580,800 m.
      See Also:
    • CONST_PC

      public static final double CONST_PC
      Constant for the parsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m.
      See Also:
    • SI_UNIT

      public static final SIUnit SI_UNIT
      The dimensions of the length: m.
    • m

      public static final Length.Unit m
      meter.
    • SI

      public static final Length.Unit SI
      The SI or BASE unit.
    • dam

      public static final Length.Unit dam
      decameter.
    • hm

      public static final Length.Unit hm
      hectometer.
    • km

      public static final Length.Unit km
      kilometer.
    • dm

      public static final Length.Unit dm
      decimeter.
    • cm

      public static final Length.Unit cm
      centimeter.
    • mm

      public static final Length.Unit mm
      millimeter.
    • mum

      public static final Length.Unit mum
      micrometer.
    • nm

      public static final Length.Unit nm
      nanometer.
    • pm

      public static final Length.Unit pm
      picometer.
    • am

      public static final Length.Unit am
      attometer.
    • fm

      public static final Length.Unit fm
      femtometer.
    • ft

      public static final Length.Unit ft
      foot (international) = 0.3048 m = 1/3 yd = 12 inches.
    • in

      public static final Length.Unit in
      inch (international) = 2.54 cm = 1/36 yd = 1/12 ft.
    • yd

      public static final Length.Unit yd
      yard (international) = 0.9144 m = 3 ft = 36 in.
    • mi

      public static final Length.Unit mi
      mile (international) = 5280 ft = 1760 yd.
    • NM

      public static final Length.Unit NM
      nautical mile (international) = 1852 m.
    • AU

      public static final Length.Unit AU
      Astronomical Unit = 149,597,870,700 m.
    • ly

      public static final Length.Unit ly
      Lightyear = 9,460,730,472,580,800 m.
    • pc

      public static final Length.Unit pc
      Parsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m.
    • A

      public static final Length.Unit A
      Angstrom = 10^-10 m.
  • Constructor Details

    • Unit

      public Unit(String id, String name, double scaleFactorToBaseUnit, UnitSystem unitSystem)
      Create a new length unit.
      Parameters:
      id - the id or main abbreviation of the unit
      name - the full name of the unit
      scaleFactorToBaseUnit - the scale factor of the unit to convert it TO the base (SI) unit
      unitSystem - the unit system such as SI or IMPERIAL
    • Unit

      public Unit(String textualAbbreviation, String displayAbbreviation, String name, Scale scale, UnitSystem unitSystem)
      Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
      Parameters:
      textualAbbreviation - the textual abbreviation of the unit, which doubles as the id
      displayAbbreviation - the display abbreviation of the unit
      name - the full name of the unit
      scale - the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
      unitSystem - unit system, e.g. SI or Imperial
  • Method Details

    • siUnit

      public SIUnit siUnit()
      Description copied from interface: UnitInterface
      Return the SI unit for this unit.
      Returns:
      the SI unit for this unit
    • getBaseUnit

      public Length.Unit getBaseUnit()
      Description copied from interface: UnitInterface
      Return the base unit for this unit.
      Returns:
      the base unit for this unit
    • ofSi

      public Length ofSi(double si)
      Description copied from interface: UnitInterface
      Return an SI-quantity for this unit with a value.
      Parameters:
      si - the value in SI or BASE units
      Returns:
      an SI-quantity for this unit with the given si-value
    • deriveUnit

      public Length.Unit deriveUnit(String textualAbbreviation, String displayAbbreviation, String name, double scaleFactor, UnitSystem unitSystem)
      Description copied from class: AbstractUnit
      Return a linearly scaled derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
      Specified by:
      deriveUnit in class AbstractUnit<Length.Unit,Length>
      Parameters:
      textualAbbreviation - the textual abbreviation of the unit, which doubles as the id
      displayAbbreviation - the display abbreviation of the unit
      name - the full name of the unit
      scaleFactor - the (linear) scale factor to multiply with the current (linear) scale factor
      unitSystem - unit system, e.g. SI or Imperial
      Returns:
      a derived unit for this unit