View Javadoc
1   package org.opentrafficsim.core.unit;
2   
3   import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.OTHER;
4   import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_ACCEPTED;
5   import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_DERIVED;
6   
7   import org.opentrafficsim.core.unit.unitsystem.UnitSystem;
8   
9   /**
10   * Standard slope angle unit. Several conversion factors have been taken from <a
11   * href="http://en.wikipedia.org/wiki/Conversion_of_units">http://en.wikipedia.org/wiki/Conversion_of_units</a>.
12   * <p>
13   * Copyright (c) 2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
15   * <p>
16   * @version May 15, 2014 <br>
17   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18   */
19  public class AngleSlopeUnit extends Unit<AngleSlopeUnit>
20  {
21      /** */
22      private static final long serialVersionUID = 20140607L;
23  
24      /** The SI unit for slope angle is radian. */
25      public static final AngleSlopeUnit SI;
26  
27      /** radian. */
28      public static final AngleSlopeUnit RADIAN;
29  
30      /** percent. */
31      // TODO: PERCENT unit. Non-linear.  
32      // public static final AngleSlopeUnit PERCENT;
33      
34      /** degree. */
35      public static final AngleSlopeUnit DEGREE;
36  
37      /** arcminute. */
38      public static final AngleSlopeUnit ARCMINUTE;
39  
40      /** arcsecond. */
41      public static final AngleSlopeUnit ARCSECOND;
42  
43      /** grad. */
44      public static final AngleSlopeUnit GRAD;
45  
46      /** centesimal arcminute. */
47      public static final AngleSlopeUnit CENTESIMAL_ARCMINUTE;
48  
49      /** centesimal arcsecond. */
50      public static final AngleSlopeUnit CENTESIMAL_ARCSECOND;
51  
52      static
53      {
54          SI = new AngleSlopeUnit("AngleSlopeUnit.radian", "AngleSlopeUnit.rad", SI_DERIVED);
55          RADIAN = SI;
56          DEGREE =
57                  new AngleSlopeUnit("AngleSlopeUnit.degree", "AngleSlopeUnit.deg", SI_ACCEPTED, RADIAN, Math.PI / 180.0);
58          ARCMINUTE =
59                  new AngleSlopeUnit("AngleSlopeUnit.arcminute", "AngleSlopeUnit.arcmin", SI_ACCEPTED, DEGREE, 1.0 / 60.0);
60          ARCSECOND =
61                  new AngleSlopeUnit("AngleSlopeUnit.arcsecond", "AngleSlopeUnit.arcsec", SI_ACCEPTED, DEGREE,
62                          1.0 / 3600.0);
63          GRAD =
64                  new AngleSlopeUnit("AngleSlopeUnit.gradian", "AngleSlopeUnit.grad", OTHER, RADIAN,
65                          2.0 * Math.PI / 400.0);
66          CENTESIMAL_ARCMINUTE =
67                  new AngleSlopeUnit("AngleSlopeUnit.centesimal_arcminute", "AngleSlopeUnit.centesimal_arcmin", OTHER,
68                          GRAD, 1.0 / 100.0);
69          CENTESIMAL_ARCSECOND =
70                  new AngleSlopeUnit("AngleSlopeUnit.centesimal_arcsecond", "AngleSlopeUnit.centesimal_arcsec", OTHER,
71                          GRAD, 1.0 / 10000.0);
72      }
73  
74      /**
75       * Build a standard unit.
76       * @param nameKey the key to the locale file for the long name of the unit
77       * @param abbreviationKey the key to the locale file for the abbreviation of the unit
78       * @param unitSystem the unit system, e.g. SI or Imperial
79       */
80      public AngleSlopeUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
81      {
82          super(nameKey, abbreviationKey, unitSystem, true);
83      }
84  
85      /**
86       * Build a unit by converting it from another unit.
87       * @param nameKey the key to the locale file for the long name of the unit
88       * @param abbreviationKey the key to the locale file for the abbreviation of the unit
89       * @param unitSystem the unit system, e.g. SI or Imperial
90       * @param referenceUnit the unit to convert to
91       * @param conversionFactorToReferenceUnit multiply a value in this unit by the factor to convert to the given
92       *            reference unit
93       */
94      public AngleSlopeUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
95              final AngleSlopeUnit referenceUnit, final double conversionFactorToReferenceUnit)
96      {
97          super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
98      }
99  
100     /** {@inheritDoc} */
101     @Override
102     public final AngleSlopeUnit getStandardUnit()
103     {
104         return RADIAN;
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public final String getSICoefficientsString()
110     {
111         return "";
112     }
113 
114 }