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