View Javadoc
1   package org.djunits.unit;
2   
3   import org.djunits.unit.quantity.Quantity;
4   import org.djunits.unit.scale.OffsetLinearScale;
5   import org.djunits.unit.si.SIPrefixes;
6   import org.djunits.unit.unitsystem.UnitSystem;
7   
8   /**
9    * Standard absolute position units.
10   * <p>
11   * Copyright (c) 2015-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
13   * <p>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   */
16  public class PositionUnit extends AbsoluteLinearUnit<PositionUnit, LengthUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The base, with "m" as the SI signature. */
22      public static final Quantity<PositionUnit> BASE = new Quantity<>("Position", "m");
23  
24      /** The SI unit for position is meter. */
25      public static final PositionUnit DEFAULT =
26              new PositionUnit().build(new AbsoluteLinearUnit.Builder<PositionUnit, LengthUnit>().setQuantity(BASE).setId("m")
27                      .setName("meter").setUnitSystem(UnitSystem.SI_BASE).setSiPrefixes(SIPrefixes.UNIT, 1.0)
28                      .setScale(new OffsetLinearScale(1.0, 0.0)).setRelativeUnit(LengthUnit.METER));
29  
30      /** meter. */
31      public static final PositionUnit METER = DEFAULT;
32  
33      /** nm. */
34      public static final PositionUnit NANOMETER = METER.deriveSI(SIPrefixes.getUnit("n"), 1.0);
35  
36      /** &#181;m. */
37      public static final PositionUnit MICROMETER = METER.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
38  
39      /** mm. */
40      public static final PositionUnit MILLIMETER = METER.deriveSI(SIPrefixes.getUnit("m"), 1.0);
41  
42      /** cm. */
43      public static final PositionUnit CENTIMETER = METER.deriveSI(SIPrefixes.getUnit("c"), 1.0);
44  
45      /** dm. */
46      public static final PositionUnit DECIMETER = METER.deriveSI(SIPrefixes.getUnit("d"), 1.0);
47  
48      /** dam. */
49      public static final PositionUnit DECAMETER = METER.deriveSI(SIPrefixes.getUnit("da"), 1.0);
50  
51      /** hm. */
52      public static final PositionUnit HECTOMETER = METER.deriveSI(SIPrefixes.getUnit("h"), 1.0);
53  
54      /** km. */
55      public static final PositionUnit KILOMETER = METER.deriveSI(SIPrefixes.getUnit("k"), 1.0);
56  
57      /** foot (international) = 0.3048 m = 1/3 yd = 12 inches. */
58      public static final PositionUnit FOOT =
59              METER.deriveLinearOffset(0.3048, 0.0, LengthUnit.FOOT, "ft", "foot", UnitSystem.IMPERIAL);
60  
61      /** inch (international) = 2.54 cm = 1/36 yd = 1/12 ft. */
62      public static final PositionUnit INCH =
63              METER.deriveLinearOffset(0.3048 / 12.0, 0.0, LengthUnit.INCH, "in", "inch", UnitSystem.IMPERIAL);
64  
65      /** yard (international) = 0.9144 m = 3 ft = 36 in. */
66      public static final PositionUnit YARD =
67              METER.deriveLinearOffset(0.3048 * 3.0, 0.0, LengthUnit.YARD, "yd", "yard", UnitSystem.IMPERIAL);
68  
69      /** mile (international) = 5280 ft = 1760 yd. */
70      public static final PositionUnit MILE =
71              METER.deriveLinearOffset(0.3048 * 5280.0, 0.0, LengthUnit.MILE, "mi", "mile", UnitSystem.IMPERIAL);
72  
73      /** nautical mile (international) = 1852 m. */
74      public static final PositionUnit NAUTICAL_MILE =
75              METER.deriveLinearOffset(1852.0, 0.0, LengthUnit.NAUTICAL_MILE, "NM", "nautical mile", UnitSystem.OTHER);
76  
77      /** Astronomical Unit = 149,597,870,700 m. */
78      public static final PositionUnit ASTRONOMICAL_UNIT = METER.deriveLinearOffset(149597870700.0, 0.0,
79              LengthUnit.ASTRONOMICAL_UNIT, "AU", "Astronomical Unit", UnitSystem.OTHER);
80  
81      /** Lightyear = 9,460,730,472,580,800 m. */
82      public static final PositionUnit LIGHTYEAR =
83              METER.deriveLinearOffset(9_460_730_472_580_800.0, 0.0, LengthUnit.LIGHTYEAR, "ly", "lightyear", UnitSystem.OTHER);
84  
85      /** Parsec = 648,000 / PI ly. */
86      public static final PositionUnit PARSEC = METER.deriveLinearOffset(9_460_730_472_580_800.0 * 648_000.0 / Math.PI, 0.0,
87              LengthUnit.PARSEC, "Pc", "Parsec", UnitSystem.OTHER);
88  
89      /** Angstrom = 10^-10 m. */
90      public static final PositionUnit ANGSTROM =
91              METER.deriveLinearOffset(1.0E-10, 0.0, LengthUnit.ANGSTROM, "A", "Angstrom", UnitSystem.OTHER, "\u212B", "A");
92  
93  }