1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AngleUnit;
6 import org.djunits.unit.AngularAccelerationUnit;
7 import org.djunits.unit.AngularVelocityUnit;
8 import org.djunits.unit.DimensionlessUnit;
9 import org.djunits.unit.DurationUnit;
10 import org.djunits.unit.FrequencyUnit;
11 import org.djunits.value.vfloat.scalar.base.FloatScalar;
12 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
13 import org.djutils.base.NumberParser;
14 import org.djutils.exceptions.Throw;
15
16 import jakarta.annotation.Generated;
17
18
19
20
21
22
23
24
25
26
27 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
28 public class FloatAngularVelocity extends FloatScalarRel<AngularVelocityUnit, FloatAngularVelocity>
29 {
30
31 private static final long serialVersionUID = 20150901L;
32
33
34 public static final FloatAngularVelocity ZERO = new FloatAngularVelocity(0.0f, AngularVelocityUnit.SI);
35
36
37 public static final FloatAngularVelocity ONE = new FloatAngularVelocity(1.0f, AngularVelocityUnit.SI);
38
39
40 @SuppressWarnings("checkstyle:constantname")
41 public static final FloatAngularVelocity NaN = new FloatAngularVelocity(Float.NaN, AngularVelocityUnit.SI);
42
43
44 public static final FloatAngularVelocity POSITIVE_INFINITY =
45 new FloatAngularVelocity(Float.POSITIVE_INFINITY, AngularVelocityUnit.SI);
46
47
48 public static final FloatAngularVelocity NEGATIVE_INFINITY =
49 new FloatAngularVelocity(Float.NEGATIVE_INFINITY, AngularVelocityUnit.SI);
50
51
52 public static final FloatAngularVelocity POS_MAXVALUE = new FloatAngularVelocity(Float.MAX_VALUE, AngularVelocityUnit.SI);
53
54
55 public static final FloatAngularVelocity NEG_MAXVALUE = new FloatAngularVelocity(-Float.MAX_VALUE, AngularVelocityUnit.SI);
56
57
58
59
60
61
62 public FloatAngularVelocity(final float value, final AngularVelocityUnit unit)
63 {
64 super(value, unit);
65 }
66
67
68
69
70
71 public FloatAngularVelocity(final FloatAngularVelocity value)
72 {
73 super(value);
74 }
75
76
77
78
79
80
81 public FloatAngularVelocity(final double value, final AngularVelocityUnit unit)
82 {
83 super((float) value, unit);
84 }
85
86
87 @Override
88 public final FloatAngularVelocity instantiateRel(final float value, final AngularVelocityUnit unit)
89 {
90 return new FloatAngularVelocity(value, unit);
91 }
92
93
94
95
96
97
98 public static final FloatAngularVelocity instantiateSI(final float value)
99 {
100 return new FloatAngularVelocity(value, AngularVelocityUnit.SI);
101 }
102
103
104
105
106
107
108
109
110 public static FloatAngularVelocity interpolate(final 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
119
120
121
122
123 public static FloatAngularVelocity max(final FloatAngularVelocity r1, final FloatAngularVelocity r2)
124 {
125 return r1.gt(r2) ? r1 : r2;
126 }
127
128
129
130
131
132
133
134
135 public static FloatAngularVelocity max(final 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
151
152
153
154
155 public static FloatAngularVelocity min(final FloatAngularVelocity r1, final FloatAngularVelocity r2)
156 {
157 return r1.lt(r2) ? r1 : r2;
158 }
159
160
161
162
163
164
165
166
167 public static FloatAngularVelocity min(final 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
183
184
185
186
187
188
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 try
196 {
197 NumberParser numberParser = new NumberParser().lenient().trailing();
198 float f = numberParser.parseFloat(text);
199 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
200 AngularVelocityUnit unit = AngularVelocityUnit.BASE.getUnitByAbbreviation(unitString);
201 if (unit == null)
202 throw new IllegalArgumentException("Unit " + unitString + " not found");
203 return new FloatAngularVelocity(f, unit);
204 }
205 catch (Exception exception)
206 {
207 throw new IllegalArgumentException("Error parsing FloatAngularVelocity from " + text + " using Locale "
208 + Locale.getDefault(Locale.Category.FORMAT), exception);
209 }
210 }
211
212
213
214
215
216
217
218
219
220 public static FloatAngularVelocity of(final float value, final String unitString)
221 {
222 Throw.whenNull(unitString, "Error parsing FloatAngularVelocity: unitString is null");
223 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
224 "Error parsing FloatAngularVelocity: empty unitString");
225 AngularVelocityUnit unit = AngularVelocityUnit.BASE.getUnitByAbbreviation(unitString);
226 if (unit != null)
227 {
228 return new FloatAngularVelocity(value, unit);
229 }
230 throw new IllegalArgumentException("Error parsing FloatAngularVelocity with unit " + unitString);
231 }
232
233
234
235
236
237
238 public final FloatDimensionless divide(final FloatAngularVelocity v)
239 {
240 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
241 }
242
243
244
245
246
247
248 public final FloatFrequency divide(final FloatAngle v)
249 {
250 return new FloatFrequency(this.si / v.si, FrequencyUnit.SI);
251 }
252
253
254
255
256
257
258 public final FloatAngle divide(final FloatFrequency v)
259 {
260 return new FloatAngle(this.si / v.si, AngleUnit.SI);
261 }
262
263
264
265
266
267
268 public final FloatAngle times(final FloatDuration v)
269 {
270 return new FloatAngle(this.si * v.si, AngleUnit.SI);
271 }
272
273
274
275
276
277
278 public final FloatAngularAcceleration divide(final FloatDuration v)
279 {
280 return new FloatAngularAcceleration(this.si / v.si, AngularAccelerationUnit.SI);
281 }
282
283
284
285
286
287
288 public final FloatDuration divide(final FloatAngularAcceleration v)
289 {
290 return new FloatDuration(this.si / v.si, DurationUnit.SI);
291 }
292
293
294
295
296
297
298
299 public final FloatAngularAcceleration times(final FloatFrequency v)
300 {
301 return new FloatAngularAcceleration(this.si * v.si, AngularAccelerationUnit.SI);
302 }
303
304
305 @Override
306 public FloatSIScalar reciprocal()
307 {
308 return FloatScalar.divide(FloatDimensionless.ONE, this);
309 }
310
311 }