View Javadoc
1   package org.djunits.value.vdouble.scalar;
2   
3   import org.djunits.unit.AngleSolidUnit;
4   import org.djunits.unit.DimensionlessUnit;
5   
6   /**
7    * Easy access methods for the AngleSolid DoubleScalar, which is relative by definition. Instead of:
8    * 
9    * <pre>
10   * DoubleScalar.Rel&lt;AngleSolidUnit&gt; value = new DoubleScalar.Rel&lt;AngleSolidUnit&gt;(100.0, AngleSolidUnit.SI);
11   * </pre>
12   * 
13   * we can now write:
14   * 
15   * <pre>
16   * AngleSolid value = new AngleSolid(100.0, AngleSolidUnit.SI);
17   * </pre>
18   * 
19   * The compiler will automatically recognize which units belong to which quantity, and whether the quantity type and the unit
20   * used are compatible.
21   * <p>
22   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
23   * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
24   * <p>
25   * $LastChangedDate: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, by $Author: averbraeck $,
26   * initial version Sep 5, 2015 <br>
27   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
28   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
29   */
30  public class AngleSolid extends AbstractDoubleScalarRel<AngleSolidUnit, AngleSolid>
31  {
32      /** */
33      private static final long serialVersionUID = 20150905L;
34  
35      /** constant with value zero. */
36      public static final AngleSolid ZERO = new AngleSolid(0.0, AngleSolidUnit.SI);
37  
38      /** constant with value NaN. */
39      @SuppressWarnings("checkstyle:constantname")
40      public static final AngleSolid NaN = new AngleSolid(Double.NaN, AngleSolidUnit.SI);
41  
42      /** constant with value POSITIVE_INFINITY. */
43      public static final AngleSolid POSITIVE_INFINITY = new AngleSolid(Double.POSITIVE_INFINITY, AngleSolidUnit.SI);
44  
45      /** constant with value NEGATIVE_INFINITY. */
46      public static final AngleSolid NEGATIVE_INFINITY = new AngleSolid(Double.NEGATIVE_INFINITY, AngleSolidUnit.SI);
47  
48      /** constant with value MAX_VALUE. */
49      public static final AngleSolid POS_MAXVALUE = new AngleSolid(Double.MAX_VALUE, AngleSolidUnit.SI);
50  
51      /** constant with value -MAX_VALUE. */
52      public static final AngleSolid NEG_MAXVALUE = new AngleSolid(-Double.MAX_VALUE, AngleSolidUnit.SI);
53  
54      /**
55       * Construct AngleSolid scalar.
56       * @param value double value
57       * @param unit unit for the double value
58       */
59      public AngleSolid(final double value, final AngleSolidUnit unit)
60      {
61          super(value, unit);
62      }
63  
64      /**
65       * Construct AngleSolid scalar.
66       * @param value Scalar from which to construct this instance
67       */
68      public AngleSolid(final AngleSolid value)
69      {
70          super(value);
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public final AngleSolid instantiateRel(final double value, final AngleSolidUnit unit)
76      {
77          return new AngleSolid(value, unit);
78      }
79  
80      /**
81       * Construct AngleSolid scalar.
82       * @param value double value in SI units
83       * @return the new scalar with the SI value
84       */
85      public static final AngleSolid createSI(final double value)
86      {
87          return new AngleSolid(value, AngleSolidUnit.SI);
88      }
89  
90      /**
91       * Interpolate between two values.
92       * @param zero the low value
93       * @param one the high value
94       * @param ratio the ratio between 0 and 1, inclusive
95       * @return a Scalar at the ratio between
96       */
97      public static AngleSolid interpolate(final AngleSolid zero, final AngleSolid one, final double ratio)
98      {
99          return new AngleSolid(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getUnit()) * ratio, zero.getUnit());
100     }
101 
102     /**
103      * Return the maximum value of two relative scalars.
104      * @param r1 the first scalar
105      * @param r2 the second scalar
106      * @return the maximum value of two relative scalars
107      */
108     public static AngleSolid max(final AngleSolid r1, final AngleSolid r2)
109     {
110         return (r1.gt(r2)) ? r1 : r2;
111     }
112 
113     /**
114      * Return the maximum value of more than two relative scalars.
115      * @param r1 the first scalar
116      * @param r2 the second scalar
117      * @param rn the other scalars
118      * @return the maximum value of more than two relative scalars
119      */
120     public static AngleSolid max(final AngleSolid r1, final AngleSolid r2, final AngleSolid... rn)
121     {
122         AngleSolid maxr = (r1.gt(r2)) ? r1 : r2;
123         for (AngleSolid r : rn)
124         {
125             if (r.gt(maxr))
126             {
127                 maxr = r;
128             }
129         }
130         return maxr;
131     }
132 
133     /**
134      * Return the minimum value of two relative scalars.
135      * @param r1 the first scalar
136      * @param r2 the second scalar
137      * @return the minimum value of two relative scalars
138      */
139     public static AngleSolid min(final AngleSolid r1, final AngleSolid r2)
140     {
141         return (r1.lt(r2)) ? r1 : r2;
142     }
143 
144     /**
145      * Return the minimum value of more than two relative scalars.
146      * @param r1 the first scalar
147      * @param r2 the second scalar
148      * @param rn the other scalars
149      * @return the minimum value of more than two relative scalars
150      */
151     public static AngleSolid min(final AngleSolid r1, final AngleSolid r2, final AngleSolid... rn)
152     {
153         AngleSolid minr = (r1.lt(r2)) ? r1 : r2;
154         for (AngleSolid r : rn)
155         {
156             if (r.lt(minr))
157             {
158                 minr = r;
159             }
160         }
161         return minr;
162     }
163 
164     /**
165      * Calculate the division of AngleSolid and AngleSolid, which results in a Dimensionless scalar.
166      * @param v AngleSolid scalar
167      * @return Dimensionless scalar as a division of AngleSolid and AngleSolid
168      */
169     public final Dimensionless divideBy(final AngleSolid v)
170     {
171         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
172     }
173 
174 }