View Javadoc
1   package org.djunits.value.vdouble.scalar;
2   
3   import java.util.regex.Matcher;
4   
5   import javax.annotation.Generated;
6   
7   import org.djunits.Throw;
8   import org.djunits.unit.AngularAccelerationUnit;
9   import org.djunits.unit.AngularVelocityUnit;
10  import org.djunits.unit.DimensionlessUnit;
11  import org.djunits.unit.FrequencyUnit;
12  import org.djunits.value.util.ValueUtil;
13  import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
14  
15  /**
16   * Easy access methods for the AngularAcceleration DoubleScalar, which is relative by definition.
17   * <p>
18   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
20   * </p>
21   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
23   */
24  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
25  public class AngularAcceleration extends AbstractDoubleScalarRel<AngularAccelerationUnit, AngularAcceleration>
26  {
27      /** */
28      private static final long serialVersionUID = 20150905L;
29  
30      /** Constant with value zero. */
31      public static final AngularAccelerationularAcceleration.html#AngularAcceleration">AngularAcceleration ZERO = new AngularAcceleration(0.0, AngularAccelerationUnit.SI);
32  
33      /** Constant with value one. */
34      public static final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration ONE = new AngularAcceleration(1.0, AngularAccelerationUnit.SI);
35  
36      /** Constant with value NaN. */
37      @SuppressWarnings("checkstyle:constantname")
38      public static final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration NaN = new AngularAcceleration(Double.NaN, AngularAccelerationUnit.SI);
39  
40      /** Constant with value POSITIVE_INFINITY. */
41      public static final AngularAcceleration POSITIVE_INFINITY =
42              new AngularAcceleration(Double.POSITIVE_INFINITY, AngularAccelerationUnit.SI);
43  
44      /** Constant with value NEGATIVE_INFINITY. */
45      public static final AngularAcceleration NEGATIVE_INFINITY =
46              new AngularAcceleration(Double.NEGATIVE_INFINITY, AngularAccelerationUnit.SI);
47  
48      /** Constant with value MAX_VALUE. */
49      public static final AngularAcceleration POS_MAXVALUE =
50              new AngularAcceleration(Double.MAX_VALUE, AngularAccelerationUnit.SI);
51  
52      /** Constant with value -MAX_VALUE. */
53      public static final AngularAcceleration NEG_MAXVALUE =
54              new AngularAcceleration(-Double.MAX_VALUE, AngularAccelerationUnit.SI);
55  
56      /**
57       * Construct AngularAcceleration scalar.
58       * @param value double; the double value
59       * @param unit AngularAccelerationUnit; unit for the double value
60       */
61      public AngularAcceleration(final double value, final AngularAccelerationUnit unit)
62      {
63          super(value, unit);
64      }
65  
66      /**
67       * Construct AngularAcceleration scalar.
68       * @param value AngularAcceleration; Scalar from which to construct this instance
69       */
70      public AngularAccelerationr/AngularAcceleration.html#AngularAcceleration">AngularAcceleration(final AngularAcceleration value)
71      {
72          super(value);
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final AngularAcceleration instantiateRel(final double value, final AngularAccelerationUnit unit)
78      {
79          return new AngularAcceleration(value, unit);
80      }
81  
82      /**
83       * Construct AngularAcceleration scalar.
84       * @param value double; the double value in SI units
85       * @return AngularAcceleration; the new scalar with the SI value
86       */
87      public static final AngularAcceleration instantiateSI(final double value)
88      {
89          return new AngularAcceleration(value, AngularAccelerationUnit.SI);
90      }
91  
92      /**
93       * Interpolate between two values.
94       * @param zero AngularAcceleration; the low value
95       * @param one AngularAcceleration; the high value
96       * @param ratio double; the ratio between 0 and 1, inclusive
97       * @return AngularAcceleration; a Scalar at the ratio between
98       */
99      public static AngularAccelerationlarAcceleration.html#AngularAcceleration">AngularAccelerationeleration.html#AngularAcceleration">AngularAcceleration interpolate(final AngularAccelerationlarAcceleration.html#AngularAcceleration">AngularAcceleration zero, final AngularAcceleration one,
100             final double ratio)
101     {
102         return new AngularAcceleration(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
103                 zero.getDisplayUnit());
104     }
105 
106     /**
107      * Return the maximum value of two relative scalars.
108      * @param r1 AngularAcceleration; the first scalar
109      * @param r2 AngularAcceleration; the second scalar
110      * @return AngularAcceleration; the maximum value of two relative scalars
111      */
112     public static AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration max(final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration r1, final AngularAcceleration r2)
113     {
114         return r1.gt(r2) ? r1 : r2;
115     }
116 
117     /**
118      * Return the maximum value of more than two relative scalars.
119      * @param r1 AngularAcceleration; the first scalar
120      * @param r2 AngularAcceleration; the second scalar
121      * @param rn AngularAcceleration...; the other scalars
122      * @return AngularAcceleration; the maximum value of more than two relative scalars
123      */
124     public static AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration max(final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration r1, final AngularAcceleration r2,
125             final AngularAcceleration... rn)
126     {
127         AngularAcceleration maxr = r1.gt(r2) ? r1 : r2;
128         for (AngularAcceleration r : rn)
129         {
130             if (r.gt(maxr))
131             {
132                 maxr = r;
133             }
134         }
135         return maxr;
136     }
137 
138     /**
139      * Return the minimum value of two relative scalars.
140      * @param r1 AngularAcceleration; the first scalar
141      * @param r2 AngularAcceleration; the second scalar
142      * @return AngularAcceleration; the minimum value of two relative scalars
143      */
144     public static AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration min(final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration r1, final AngularAcceleration r2)
145     {
146         return r1.lt(r2) ? r1 : r2;
147     }
148 
149     /**
150      * Return the minimum value of more than two relative scalars.
151      * @param r1 AngularAcceleration; the first scalar
152      * @param r2 AngularAcceleration; the second scalar
153      * @param rn AngularAcceleration...; the other scalars
154      * @return AngularAcceleration; the minimum value of more than two relative scalars
155      */
156     public static AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration min(final AngularAccelerationgularAcceleration.html#AngularAcceleration">AngularAcceleration r1, final AngularAcceleration r2,
157             final AngularAcceleration... rn)
158     {
159         AngularAcceleration minr = r1.lt(r2) ? r1 : r2;
160         for (AngularAcceleration r : rn)
161         {
162             if (r.lt(minr))
163             {
164                 minr = r;
165             }
166         }
167         return minr;
168     }
169 
170     /**
171      * Returns a AngularAcceleration representation of a textual representation of a value with a unit. The String
172      * representation that can be parsed is the double value in the unit, followed by the official abbreviation of the unit.
173      * Spaces are allowed, but not required, between the value and the unit.
174      * @param text String; the textual representation to parse into a AngularAcceleration
175      * @return AngularAcceleration; the Scalar representation of the value in its unit
176      * @throws IllegalArgumentException when the text cannot be parsed
177      * @throws NullPointerException when the text argument is null
178      */
179     public static AngularAcceleration valueOf(final String text)
180     {
181         Throw.whenNull(text, "Error parsing AngularAcceleration: text to parse is null");
182         Throw.when(text.length() == 0, IllegalArgumentException.class,
183                 "Error parsing AngularAcceleration: empty text to parse");
184         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
185         if (matcher.find())
186         {
187             int index = matcher.end();
188             String unitString = text.substring(index).trim();
189             String valueString = text.substring(0, index).trim();
190             AngularAccelerationUnit unit = AngularAccelerationUnit.BASE.getUnitByAbbreviation(unitString);
191             if (unit != null)
192             {
193                 double d = Double.parseDouble(valueString);
194                 return new AngularAcceleration(d, unit);
195             }
196         }
197         throw new IllegalArgumentException("Error parsing AngularAcceleration from " + text);
198     }
199 
200     /**
201      * Returns a AngularAcceleration based on a value and the textual representation of the unit.
202      * @param value double; the value to use
203      * @param unitString String; the textual representation of the unit
204      * @return AngularAcceleration; the Scalar representation of the value in its unit
205      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
206      * @throws NullPointerException when the unitString argument is null
207      */
208     public static AngularAcceleration of(final double value, final String unitString)
209     {
210         Throw.whenNull(unitString, "Error parsing AngularAcceleration: unitString is null");
211         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
212                 "Error parsing AngularAcceleration: empty unitString");
213         AngularAccelerationUnit unit = AngularAccelerationUnit.BASE.getUnitByAbbreviation(unitString);
214         if (unit != null)
215         {
216             return new AngularAcceleration(value, unit);
217         }
218         throw new IllegalArgumentException("Error parsing AngularAcceleration with unit " + unitString);
219     }
220 
221     /**
222      * Calculate the division of AngularAcceleration and AngularAcceleration, which results in a Dimensionless scalar.
223      * @param v AngularAcceleration scalar
224      * @return Dimensionless scalar as a division of AngularAcceleration and AngularAcceleration
225      */
226     public final Dimensionless divide(final AngularAcceleration v)
227     {
228         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
229     }
230 
231     /**
232      * Calculate the multiplication of AngularAcceleration and Duration, which results in a AngularVelocity scalar.
233      * @param v AngularAcceleration scalar
234      * @return AngularVelocity scalar as a multiplication of AngularAcceleration and Duration
235      */
236     public final AngularVelocity times(final Duration v)
237     {
238         return new AngularVelocity(this.si * v.si, AngularVelocityUnit.SI);
239     }
240 
241     /**
242      * Calculate the division of AngularAcceleration and Frequency, which results in a AngularVelocity scalar.
243      * @param v AngularAcceleration scalar
244      * @return AngularVelocity scalar as a division of AngularAcceleration and Frequency
245      */
246     public final AngularVelocity divide(final Frequency v)
247     {
248         return new AngularVelocity(this.si / v.si, AngularVelocityUnit.SI);
249     }
250 
251     /**
252      * Calculate the division of AngularAcceleration and AngularVelocity, which results in a Frequency scalar.
253      * @param v AngularAcceleration scalar
254      * @return Frequency scalar as a division of AngularAcceleration and AngularVelocity
255      */
256     public final Frequency divide(final AngularVelocity v)
257     {
258         return new Frequency(this.si / v.si, FrequencyUnit.SI);
259     }
260 
261 }