Package org.djunits.quantity
Class Length.Unit
- All Implemented Interfaces:
UnitInterface<Length.Unit,Length>
- Enclosing class:
- 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Length.UnitAngstrom = 10^-10 m.static final Length.Unitattometer.static final Length.UnitAstronomical Unit = 149,597,870,700 m.static final Length.Unitcentimeter.static final doubleConstant for the Astronomical Unit = 149,597,870,700 m.static final doubleConstant for the foot.static final doubleConstant for the inch.static final doubleConstant for the lightyear = 9,460,730,472,580,800 m.static final doubleConstant for the mile.static final doubleConstant for the nautical mile.static final doubleConstant for the parsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m.static final doubleConstant for the yard.static final Length.Unitdecameter.static final Length.Unitdecimeter.static final Length.Unitfemtometer.static final Length.Unitfoot (international) = 0.3048 m = 1/3 yd = 12 inches.static final Length.Unithectometer.static final Length.Unitinch (international) = 2.54 cm = 1/36 yd = 1/12 ft.static final Length.Unitkilometer.static final Length.UnitLightyear = 9,460,730,472,580,800 m.static final Length.Unitmeter.static final Length.Unitmile (international) = 5280 ft = 1760 yd.static final Length.Unitmillimeter.static final Length.Unitmicrometer.static final Length.Unitnanometer.static final Length.Unitnautical mile (international) = 1852 m.static final Length.UnitParsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m.static final Length.Unitpicometer.static final Length.UnitThe SI or BASE unit.static final SIUnitThe dimensions of the length: m.static final Length.Unityard (international) = 0.9144 m = 3 ft = 36 in. -
Constructor Summary
ConstructorsConstructorDescriptionUnit(String id, String name, double scaleFactorToBaseUnit, UnitSystem unitSystem) Create a new length unit.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. -
Method Summary
Modifier and TypeMethodDescriptionderiveUnit(String textualAbbreviation, String displayAbbreviation, String name, double scaleFactor, UnitSystem unitSystem) Return a linearly scaled derived unit for this unit, with textual abbreviation(s) and a display abbreviation.Return the base unit for this unit.ofSi(double si) Return an SI-quantity for this unit with a value.siUnit()Return the SI unit for this unit.Methods inherited from class org.djunits.unit.AbstractUnit
deriveUnit, equals, generateSiPrefixes, getDisplayAbbreviation, getId, getName, getScale, getSiPrefix, getStoredDisplayAbbreviation, getStoredName, getStoredTextualAbbreviation, getTextualAbbreviation, getUnitSystem, hashCode, setSiPrefix, setSiPrefix, setSiPrefixKilo, setSiPrefixPer, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.unit.UnitInterface
fromBaseValue, quantityInUnit, toBaseValue
-
Field Details
-
CONST_FT
public static final double CONST_FTConstant for the foot.- See Also:
-
CONST_YD
public static final double CONST_YDConstant for the yard.- See Also:
-
CONST_IN
public static final double CONST_INConstant for the inch.- See Also:
-
CONST_MI
public static final double CONST_MIConstant for the mile.- See Also:
-
CONST_NM
public static final double CONST_NMConstant for the nautical mile.- See Also:
-
CONST_AU
public static final double CONST_AUConstant for the Astronomical Unit = 149,597,870,700 m.- See Also:
-
CONST_LY
public static final double CONST_LYConstant for the lightyear = 9,460,730,472,580,800 m.- See Also:
-
CONST_PC
public static final double CONST_PCConstant for the parsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m.- See Also:
-
SI_UNIT
The dimensions of the length: m. -
m
meter. -
SI
The SI or BASE unit. -
dam
decameter. -
hm
hectometer. -
km
kilometer. -
dm
decimeter. -
cm
centimeter. -
mm
millimeter. -
mum
micrometer. -
nm
nanometer. -
pm
picometer. -
am
attometer. -
fm
femtometer. -
ft
foot (international) = 0.3048 m = 1/3 yd = 12 inches. -
in
inch (international) = 2.54 cm = 1/36 yd = 1/12 ft. -
yd
yard (international) = 0.9144 m = 3 ft = 36 in. -
mi
mile (international) = 5280 ft = 1760 yd. -
NM
nautical mile (international) = 1852 m. -
AU
Astronomical Unit = 149,597,870,700 m. -
ly
Lightyear = 9,460,730,472,580,800 m. -
pc
Parsec = AU / tan(1 arcsecond) = AU * 648,000 / PI m. -
A
Angstrom = 10^-10 m.
-
-
Constructor Details
-
Unit
Create a new length unit.- Parameters:
id- the id or main abbreviation of the unitname- the full name of the unitscaleFactorToBaseUnit- the scale factor of the unit to convert it TO the base (SI) unitunitSystem- 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 iddisplayAbbreviation- the display abbreviation of the unitname- the full name of the unitscale- the scale to use to convert between this unit and the standard (e.g., SI, BASE) unitunitSystem- unit system, e.g. SI or Imperial
-
-
Method Details
-
siUnit
Description copied from interface:UnitInterfaceReturn the SI unit for this unit.- Returns:
- the SI unit for this unit
-
getBaseUnit
Description copied from interface:UnitInterfaceReturn the base unit for this unit.- Returns:
- the base unit for this unit
-
ofSi
Description copied from interface:UnitInterfaceReturn 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:AbstractUnitReturn a linearly scaled derived unit for this unit, with textual abbreviation(s) and a display abbreviation.- Specified by:
deriveUnitin classAbstractUnit<Length.Unit,Length> - Parameters:
textualAbbreviation- the textual abbreviation of the unit, which doubles as the iddisplayAbbreviation- the display abbreviation of the unitname- the full name of the unitscaleFactor- the (linear) scale factor to multiply with the current (linear) scale factorunitSystem- unit system, e.g. SI or Imperial- Returns:
- a derived unit for this unit
-