Package org.djunits.quantity
Class Volume.Unit
- All Implemented Interfaces:
UnitInterface<Volume.Unit,Volume>
- Enclosing class:
- Volume
Volume.Unit encodes the volume unit (length x length x length).
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 Volume.Unitcm^3.static final doubleConstant for the cubic foot.static final doubleConstant for the cubic inch.static final doubleConstant for the cubic yard.static final doubleConstant for the imperial gallon.static final doubleConstant for US gallon.static final doubleConstant for imperial fluid ounce.static final doubleConstant for US fluid ounce.static final Volume.Unitdam^3.static final Volume.Unitdm^3.static final Volume.Unitounce (fluid imperial) = 1/20 imp pint.static final Volume.Unitounce (fluid US) = 1/16 US pint.static final Volume.Unitft^3.static final Volume.Unitgallon (imperial).static final Volume.Unitgallon (US), fluids.static final Volume.Unithm^3.static final Volume.Unitin^3.static final Volume.Unitkm^3.static final Volume.Unitliter.static final Volume.UnitCubic lightyear.static final Volume.UnitCubic meter.static final Volume.Unitmile^3.static final Volume.Unitmm^3.static final Volume.UnitNautical mile^3.static final Volume.UnitCubic Parsec.static final Volume.Unitpint (imperial) = 1/2 imp quart.static final Volume.Unitpint (fluid US) = 1/2 US quart.static final Volume.Unitquart (imperial) = 1/4 imp gallon.static final Volume.Unitquart (fluid US) = 1/4 US gallon.static final Volume.UnitThe SI or BASE unit.static final SIUnitThe dimensions of Volume: m3.static final Volume.Unityd^3. -
Constructor Summary
ConstructorsConstructorDescriptionUnit(String id, String name, double scaleFactorToBaseUnit, UnitSystem unitSystem) Create a new Volume 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_CUBIC_INCH
public static final double CONST_CUBIC_INCHConstant for the cubic inch. -
CONST_CUBIC_FOOT
public static final double CONST_CUBIC_FOOTConstant for the cubic foot. -
CONST_CUBIC_YARD
public static final double CONST_CUBIC_YARDConstant for the cubic yard. -
CONST_GALLON_IMP
public static final double CONST_GALLON_IMPConstant for the imperial gallon.- See Also:
-
CONST_OZ_IMP
public static final double CONST_OZ_IMPConstant for imperial fluid ounce.- See Also:
-
CONST_GALLON_US
public static final double CONST_GALLON_USConstant for US gallon. -
CONST_OZ_US
public static final double CONST_OZ_USConstant for US fluid ounce. -
SI_UNIT
The dimensions of Volume: m3. -
m3
Cubic meter. -
SI
The SI or BASE unit. -
mm3
mm^3. -
cm3
cm^3. -
dm3
dm^3. -
dam3
dam^3. -
hm3
hm^3. -
km3
km^3. -
in3
in^3. -
ft3
ft^3. -
yd3
yd^3. -
mi3
mile^3. -
NM3
Nautical mile^3. -
L
liter. -
gal_US
gallon (US), fluids. -
gal_imp
gallon (imperial). -
qt_US
quart (fluid US) = 1/4 US gallon. -
qt_imp
quart (imperial) = 1/4 imp gallon. -
pt_US
pint (fluid US) = 1/2 US quart. -
pt_imp
pint (imperial) = 1/2 imp quart. -
fl_oz_US
ounce (fluid US) = 1/16 US pint. -
fl_oz_imp
ounce (fluid imperial) = 1/20 imp pint. -
ly3
Cubic lightyear. -
pc3
Cubic Parsec.
-
-
Constructor Details
-
Unit
Create a new Volume 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 Volume.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<Volume.Unit,Volume> - 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
-