View Javadoc
1   package org.djunits.value.vfloat.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.vfloat.scalar.base.FloatScalar;
10  import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
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 FloatAngularAcceleration FloatScalar, 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 FloatAngularAcceleration extends FloatScalarRel<AngularAccelerationUnit, FloatAngularAcceleration>
27  {
28      /** */
29      private static final long serialVersionUID = 20150901L;
30  
31      /** Constant with value zero. */
32      public static final FloatAngularAcceleration ZERO = new FloatAngularAcceleration(0.0f, AngularAccelerationUnit.SI);
33  
34      /** Constant with value one. */
35      public static final FloatAngularAcceleration ONE = new FloatAngularAcceleration(1.0f, AngularAccelerationUnit.SI);
36  
37      /** Constant with value NaN. */
38      @SuppressWarnings("checkstyle:constantname")
39      public static final FloatAngularAcceleration NaN = new FloatAngularAcceleration(Float.NaN, AngularAccelerationUnit.SI);
40  
41      /** Constant with value POSITIVE_INFINITY. */
42      public static final FloatAngularAcceleration POSITIVE_INFINITY =
43              new FloatAngularAcceleration(Float.POSITIVE_INFINITY, AngularAccelerationUnit.SI);
44  
45      /** Constant with value NEGATIVE_INFINITY. */
46      public static final FloatAngularAcceleration NEGATIVE_INFINITY =
47              new FloatAngularAcceleration(Float.NEGATIVE_INFINITY, AngularAccelerationUnit.SI);
48  
49      /** Constant with value MAX_VALUE. */
50      public static final FloatAngularAcceleration POS_MAXVALUE =
51              new FloatAngularAcceleration(Float.MAX_VALUE, AngularAccelerationUnit.SI);
52  
53      /** Constant with value -MAX_VALUE. */
54      public static final FloatAngularAcceleration NEG_MAXVALUE =
55              new FloatAngularAcceleration(-Float.MAX_VALUE, AngularAccelerationUnit.SI);
56  
57      /**
58       * Construct FloatAngularAcceleration scalar.
59       * @param value float; the float value
60       * @param unit unit for the float value
61       */
62      public FloatAngularAcceleration(final float value, final AngularAccelerationUnit unit)
63      {
64          super(value, unit);
65      }
66  
67      /**
68       * Construct FloatAngularAcceleration scalar.
69       * @param value Scalar from which to construct this instance
70       */
71      public FloatAngularAcceleration(final FloatAngularAcceleration value)
72      {
73          super(value);
74      }
75  
76      /**
77       * Construct FloatAngularAcceleration scalar using a double value.
78       * @param value double; the double value
79       * @param unit unit for the resulting float value
80       */
81      public FloatAngularAcceleration(final double value, final AngularAccelerationUnit unit)
82      {
83          super((float) value, unit);
84      }
85  
86      @Override
87      public final FloatAngularAcceleration instantiateRel(final float value, final AngularAccelerationUnit unit)
88      {
89          return new FloatAngularAcceleration(value, unit);
90      }
91  
92      /**
93       * Construct FloatAngularAcceleration scalar.
94       * @param value float; the float value in SI units
95       * @return the new scalar with the SI value
96       */
97      public static final FloatAngularAcceleration instantiateSI(final float value)
98      {
99          return new FloatAngularAcceleration(value, AngularAccelerationUnit.SI);
100     }
101 
102     /**
103      * Interpolate between two values.
104      * @param zero the low value
105      * @param one the high value
106      * @param ratio double; the ratio between 0 and 1, inclusive
107      * @return a Scalar at the ratio between
108      */
109     public static FloatAngularAcceleration interpolate(final FloatAngularAcceleration zero, final FloatAngularAcceleration one,
110             final float ratio)
111     {
112         return new FloatAngularAcceleration(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
113                 zero.getDisplayUnit());
114     }
115 
116     /**
117      * Return the maximum value of two relative scalars.
118      * @param r1 the first scalar
119      * @param r2 the second scalar
120      * @return the maximum value of two relative scalars
121      */
122     public static FloatAngularAcceleration max(final FloatAngularAcceleration r1, final FloatAngularAcceleration r2)
123     {
124         return r1.gt(r2) ? r1 : r2;
125     }
126 
127     /**
128      * Return the maximum value of more than two relative scalars.
129      * @param r1 the first scalar
130      * @param r2 the second scalar
131      * @param rn the other scalars
132      * @return the maximum value of more than two relative scalars
133      */
134     public static FloatAngularAcceleration max(final FloatAngularAcceleration r1, final FloatAngularAcceleration r2,
135             final FloatAngularAcceleration... rn)
136     {
137         FloatAngularAcceleration maxr = r1.gt(r2) ? r1 : r2;
138         for (FloatAngularAcceleration r : rn)
139         {
140             if (r.gt(maxr))
141             {
142                 maxr = r;
143             }
144         }
145         return maxr;
146     }
147 
148     /**
149      * Return the minimum value of two relative scalars.
150      * @param r1 the first scalar
151      * @param r2 the second scalar
152      * @return the minimum value of two relative scalars
153      */
154     public static FloatAngularAcceleration min(final FloatAngularAcceleration r1, final FloatAngularAcceleration r2)
155     {
156         return r1.lt(r2) ? r1 : r2;
157     }
158 
159     /**
160      * Return the minimum value of more than two relative scalars.
161      * @param r1 the first scalar
162      * @param r2 the second scalar
163      * @param rn the other scalars
164      * @return the minimum value of more than two relative scalars
165      */
166     public static FloatAngularAcceleration min(final FloatAngularAcceleration r1, final FloatAngularAcceleration r2,
167             final FloatAngularAcceleration... rn)
168     {
169         FloatAngularAcceleration minr = r1.lt(r2) ? r1 : r2;
170         for (FloatAngularAcceleration r : rn)
171         {
172             if (r.lt(minr))
173             {
174                 minr = r;
175             }
176         }
177         return minr;
178     }
179 
180     /**
181      * Returns a FloatAngularAcceleration representation of a textual representation of a value with a unit. The String
182      * representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the
183      * unit. Spaces are allowed, but not required, between the value and the unit.
184      * @param text String; the textual representation to parse into a FloatAngularAcceleration
185      * @return FloatAngularAcceleration; the Scalar representation of the value in its unit
186      * @throws IllegalArgumentException when the text cannot be parsed
187      * @throws NullPointerException when the text argument is null
188      */
189     public static FloatAngularAcceleration valueOf(final String text)
190     {
191         Throw.whenNull(text, "Error parsing FloatAngularAcceleration: text to parse is null");
192         Throw.when(text.length() == 0, IllegalArgumentException.class,
193                 "Error parsing FloatAngularAcceleration: empty text to parse");
194         try
195         {
196             NumberParser numberParser = new NumberParser().lenient().trailing();
197             float f = numberParser.parseFloat(text);
198             String unitString = text.substring(numberParser.getTrailingPosition()).trim();
199             AngularAccelerationUnit unit = AngularAccelerationUnit.BASE.getUnitByAbbreviation(unitString);
200             if (unit == null)
201                 throw new IllegalArgumentException("Unit " + unitString + " not found");
202             return new FloatAngularAcceleration(f, unit);
203         }
204         catch (Exception exception)
205         {
206             throw new IllegalArgumentException("Error parsing FloatAngularAcceleration from " + text + " using Locale "
207                     + Locale.getDefault(Locale.Category.FORMAT), exception);
208         }
209     }
210 
211     /**
212      * Returns a FloatAngularAcceleration based on a value and the textual representation of the unit, which can be localized.
213      * @param value double; the value to use
214      * @param unitString String; the textual representation of the unit
215      * @return FloatAngularAcceleration; the Scalar representation of the value in its unit
216      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
217      * @throws NullPointerException when the unitString argument is null
218      */
219     public static FloatAngularAcceleration of(final float value, final String unitString)
220     {
221         Throw.whenNull(unitString, "Error parsing FloatAngularAcceleration: unitString is null");
222         Throw.when(unitString.length() == 0, IllegalArgumentException.class,
223                 "Error parsing FloatAngularAcceleration: empty unitString");
224         AngularAccelerationUnit unit = AngularAccelerationUnit.BASE.getUnitByAbbreviation(unitString);
225         if (unit != null)
226         {
227             return new FloatAngularAcceleration(value, unit);
228         }
229         throw new IllegalArgumentException("Error parsing FloatAngularAcceleration with unit " + unitString);
230     }
231 
232     /**
233      * Calculate the division of FloatAngularAcceleration and FloatAngularAcceleration, which results in a FloatDimensionless
234      * scalar.
235      * @param v FloatAngularAcceleration; scalar
236      * @return FloatDimensionless; scalar as a division of FloatAngularAcceleration and FloatAngularAcceleration
237      */
238     public final FloatDimensionless divide(final FloatAngularAcceleration v)
239     {
240         return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
241     }
242 
243     /**
244      * Calculate the multiplication of FloatAngularAcceleration and FloatDuration, which results in a FloatAngularVelocity
245      * scalar.
246      * @param v FloatAngularAcceleration; scalar
247      * @return FloatAngularVelocity; scalar as a multiplication of FloatAngularAcceleration and FloatDuration
248      */
249     public final FloatAngularVelocity times(final FloatDuration v)
250     {
251         return new FloatAngularVelocity(this.si * v.si, AngularVelocityUnit.SI);
252     }
253 
254     /**
255      * Calculate the division of FloatAngularAcceleration and FloatFrequency, which results in a FloatAngularVelocity scalar.
256      * @param v FloatAngularAcceleration; scalar
257      * @return FloatAngularVelocity; scalar as a division of FloatAngularAcceleration and FloatFrequency
258      */
259     public final FloatAngularVelocity divide(final FloatFrequency v)
260     {
261         return new FloatAngularVelocity(this.si / v.si, AngularVelocityUnit.SI);
262     }
263 
264     /**
265      * Calculate the division of FloatAngularAcceleration and FloatAngularVelocity, which results in a FloatFrequency scalar.
266      * @param v FloatAngularAcceleration; scalar
267      * @return FloatFrequency; scalar as a division of FloatAngularAcceleration and FloatAngularVelocity
268      */
269     public final FloatFrequency divide(final FloatAngularVelocity v)
270     {
271         return new FloatFrequency(this.si / v.si, FrequencyUnit.SI);
272     }
273 
274     @Override
275     public FloatSIScalar reciprocal()
276     {
277         return FloatScalar.divide(FloatDimensionless.ONE, this);
278     }
279 
280 }