View Javadoc
1   package org.djunits.unit;
2   
3   import org.djunits.unit.quantity.Quantity;
4   import org.djunits.unit.scale.GradeScale;
5   import org.djunits.unit.scale.IdentityScale;
6   import org.djunits.unit.si.SIPrefixes;
7   import org.djunits.unit.unitsystem.UnitSystem;
8   
9   /**
10   * Standard angle unit. Several conversion factors have been taken from
11   * <a href="http://en.wikipedia.org/wiki/Conversion_of_units">http://en.wikipedia.org/wiki/Conversion_of_units</a>.
12   * <p>
13   * Note that the Angle is <b>counter</b>clockwise.
14   * </p>
15   * <p>
16   * Copyright (c) 2015-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>
18   * </p>
19   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   */
21  public class AngleUnit extends Unit<AngleUnit>
22  {
23      /** */
24      private static final long serialVersionUID = 20140607L;
25  
26      /** The base, with "rad" as the SI signature. */
27      public static final Quantity<AngleUnit> BASE = new Quantity<>("Angle", "rad");
28  
29      /** The SI unit for angle is radian. */
30      public static final AngleUnit SI =
31              new AngleUnit().build(new Unit.Builder<AngleUnit>().setQuantity(BASE).setId("rad").setName("radians")
32                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.NONE, 1.0).setScale(IdentityScale.SCALE));
33  
34      /** radian. */
35      public static final AngleUnit RADIAN = SI;
36  
37      /** percent (non-linear, 100% is 45 degrees; 90 degrees is infinite). */
38      public static final AngleUnitleUnit">AngleUnit PERCENT = new AngleUnit().build(new Unit.Builder<AngleUnit>().setQuantity(BASE).setId("perc")
39              .setName("percent").setUnitSystem(UnitSystem.OTHER).setSiPrefixes(SIPrefixes.NONE, 1.0)
40              .setScale(new GradeScale(0.01)).setDefaultDisplayAbbreviation("%").setDefaultTextualAbbreviation("%"));
41  
42      /** degree. */
43      public static final AngleUnit DEGREE =
44              RADIAN.deriveLinear(Math.PI / 180.0, "deg", "degree", UnitSystem.SI_ACCEPTED, "\u00b0", "deg", "dg");
45  
46      /** arcminute. */
47      public static final AngleUnit ARCMINUTE =
48              DEGREE.deriveLinear(1.0 / 60.0, "arcmin", "arcminute", UnitSystem.SI_ACCEPTED, "'", "'", "arcmin");
49  
50      /** arcsecond. */
51      public static final AngleUnit ARCSECOND = DEGREE.deriveLinear(1.0 / 3600.0, "arcsec", "arcsecond", UnitSystem.SI_ACCEPTED,
52              "\"", "\"", new String[] {"arcsec"});
53  
54      /** grad. */
55      public static final AngleUnit GRAD = RADIAN.deriveLinear(2.0 * Math.PI / 400.0, "grad", "gradian", UnitSystem.OTHER);
56  
57      /** centesimal arcminute. */
58      public static final AngleUnit CENTESIMAL_ARCMINUTE =
59              GRAD.deriveLinear(1.0 / 100.0, "cdm", "centesimal arcminute", UnitSystem.OTHER, "c'", "c'");
60  
61      /** centesimal arcsecond. */
62      public static final AngleUnit CENTESIMAL_ARCSECOND =
63              GRAD.deriveLinear(1.0 / 10000.0, "cds", "centesimal arcsecond", UnitSystem.OTHER, "c\"", "c\"");
64  
65  }