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.AngularVelocityUnit;
7 import org.djunits.unit.DimensionlessUnit;
8 import org.djunits.unit.DirectionUnit;
9 import org.djunits.unit.DurationUnit;
10 import org.djunits.value.vfloat.scalar.base.FloatScalar;
11 import org.djunits.value.vfloat.scalar.base.FloatScalarRelWithAbs;
12 import org.djutils.base.NumberParser;
13 import org.djutils.exceptions.Throw;
14
15 import jakarta.annotation.Generated;
16
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 FloatAngle extends FloatScalarRelWithAbs<DirectionUnit, FloatDirection, AngleUnit, FloatAngle>
29 {
30
31 private static final long serialVersionUID = 20150901L;
32
33
34 public static final FloatAngle ZERO = new FloatAngle(0.0f, AngleUnit.SI);
35
36
37 public static final FloatAngle ONE = new FloatAngle(1.0f, AngleUnit.SI);
38
39
40 @SuppressWarnings("checkstyle:constantname")
41 public static final FloatAngle NaN = new FloatAngle(Float.NaN, AngleUnit.SI);
42
43
44 public static final FloatAngle POSITIVE_INFINITY = new FloatAngle(Float.POSITIVE_INFINITY, AngleUnit.SI);
45
46
47 public static final FloatAngle NEGATIVE_INFINITY = new FloatAngle(Float.NEGATIVE_INFINITY, AngleUnit.SI);
48
49
50 public static final FloatAngle POS_MAXVALUE = new FloatAngle(Float.MAX_VALUE, AngleUnit.SI);
51
52
53 public static final FloatAngle NEG_MAXVALUE = new FloatAngle(-Float.MAX_VALUE, AngleUnit.SI);
54
55
56
57
58
59
60 public FloatAngle(final float value, final AngleUnit unit)
61 {
62 super(value, unit);
63 }
64
65
66
67
68
69 public FloatAngle(final FloatAngle value)
70 {
71 super(value);
72 }
73
74
75
76
77
78
79 public FloatAngle(final double value, final AngleUnit unit)
80 {
81 super((float) value, unit);
82 }
83
84 @Override
85 public final FloatAngle instantiateRel(final float value, final AngleUnit unit)
86 {
87 return new FloatAngle(value, unit);
88 }
89
90
91
92
93
94
95 public static final FloatAngle instantiateSI(final float value)
96 {
97 return new FloatAngle(value, AngleUnit.SI);
98 }
99
100 @Override
101 public final FloatDirection instantiateAbs(final float value, final DirectionUnit unit)
102 {
103 return new FloatDirection(value, unit);
104 }
105
106
107
108
109
110
111
112
113 public static FloatAngle interpolate(final FloatAngle zero, final FloatAngle one, final float ratio)
114 {
115 return new FloatAngle(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
116 zero.getDisplayUnit());
117 }
118
119
120
121
122
123
124
125 public static FloatAngle max(final FloatAngle r1, final FloatAngle r2)
126 {
127 return r1.gt(r2) ? r1 : r2;
128 }
129
130
131
132
133
134
135
136
137 public static FloatAngle max(final FloatAngle r1, final FloatAngle r2, final FloatAngle... rn)
138 {
139 FloatAngle maxr = r1.gt(r2) ? r1 : r2;
140 for (FloatAngle r : rn)
141 {
142 if (r.gt(maxr))
143 {
144 maxr = r;
145 }
146 }
147 return maxr;
148 }
149
150
151
152
153
154
155
156 public static FloatAngle min(final FloatAngle r1, final FloatAngle r2)
157 {
158 return r1.lt(r2) ? r1 : r2;
159 }
160
161
162
163
164
165
166
167
168 public static FloatAngle min(final FloatAngle r1, final FloatAngle r2, final FloatAngle... rn)
169 {
170 FloatAngle minr = r1.lt(r2) ? r1 : r2;
171 for (FloatAngle 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 FloatAngle valueOf(final String text)
191 {
192 Throw.whenNull(text, "Error parsing FloatAngle: text to parse is null");
193 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing FloatAngle: 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 AngleUnit unit = AngleUnit.BASE.getUnitByAbbreviation(unitString);
200 if (unit == null)
201 throw new IllegalArgumentException("Unit " + unitString + " not found");
202 return new FloatAngle(f, unit);
203 }
204 catch (Exception exception)
205 {
206 throw new IllegalArgumentException(
207 "Error parsing FloatAngle from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
208 exception);
209 }
210 }
211
212
213
214
215
216
217
218
219
220 public static FloatAngle of(final float value, final String unitString)
221 {
222 Throw.whenNull(unitString, "Error parsing FloatAngle: unitString is null");
223 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing FloatAngle: empty unitString");
224 AngleUnit unit = AngleUnit.BASE.getUnitByAbbreviation(unitString);
225 if (unit != null)
226 {
227 return new FloatAngle(value, unit);
228 }
229 throw new IllegalArgumentException("Error parsing FloatAngle with unit " + unitString);
230 }
231
232
233
234
235
236
237 public final FloatDimensionless divide(final FloatAngle v)
238 {
239 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
240 }
241
242
243
244
245
246
247 public final FloatAngularVelocity times(final FloatFrequency v)
248 {
249 return new FloatAngularVelocity(this.si * v.si, AngularVelocityUnit.SI);
250 }
251
252
253
254
255
256
257 public final FloatAngularVelocity divide(final FloatDuration v)
258 {
259 return new FloatAngularVelocity(this.si / v.si, AngularVelocityUnit.SI);
260 }
261
262
263
264
265
266
267 public final FloatDuration divide(final FloatAngularVelocity v)
268 {
269 return new FloatDuration(this.si / v.si, DurationUnit.SI);
270 }
271
272 @Override
273 public FloatSIScalar reciprocal()
274 {
275 return FloatScalar.divide(FloatDimensionless.ONE, this);
276 }
277
278 }