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