1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.DimensionlessUnit;
6 import org.djunits.unit.LuminousFluxUnit;
7 import org.djunits.unit.SolidAngleUnit;
8 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
9 import org.djutils.base.NumberParser;
10 import org.djutils.exceptions.Throw;
11
12 import jakarta.annotation.Generated;
13
14
15
16
17
18
19
20
21
22
23 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2025-09-06T15:16:28.380798Z")
24 public class FloatSolidAngle extends FloatScalarRel<SolidAngleUnit, FloatSolidAngle>
25 {
26
27 private static final long serialVersionUID = 20150901L;
28
29
30 public static final FloatSolidAngle ZERO = new FloatSolidAngle(0.0f, SolidAngleUnit.SI);
31
32
33 public static final FloatSolidAngle ONE = new FloatSolidAngle(1.0f, SolidAngleUnit.SI);
34
35
36 @SuppressWarnings("checkstyle:constantname")
37 public static final FloatSolidAngle NaN = new FloatSolidAngle(Float.NaN, SolidAngleUnit.SI);
38
39
40 public static final FloatSolidAngle POSITIVE_INFINITY = new FloatSolidAngle(Float.POSITIVE_INFINITY, SolidAngleUnit.SI);
41
42
43 public static final FloatSolidAngle NEGATIVE_INFINITY = new FloatSolidAngle(Float.NEGATIVE_INFINITY, SolidAngleUnit.SI);
44
45
46 public static final FloatSolidAngle POS_MAXVALUE = new FloatSolidAngle(Float.MAX_VALUE, SolidAngleUnit.SI);
47
48
49 public static final FloatSolidAngle NEG_MAXVALUE = new FloatSolidAngle(-Float.MAX_VALUE, SolidAngleUnit.SI);
50
51
52
53
54
55
56 public FloatSolidAngle(final float value, final SolidAngleUnit unit)
57 {
58 super(value, unit);
59 }
60
61
62
63
64
65 public FloatSolidAngle(final FloatSolidAngle value)
66 {
67 super(value);
68 }
69
70
71
72
73
74
75 public FloatSolidAngle(final double value, final SolidAngleUnit unit)
76 {
77 super((float) value, unit);
78 }
79
80 @Override
81 public final FloatSolidAngle instantiateRel(final float value, final SolidAngleUnit unit)
82 {
83 return new FloatSolidAngle(value, unit);
84 }
85
86
87
88
89
90
91 public static final FloatSolidAngle ofSI(final float value)
92 {
93 return new FloatSolidAngle(value, SolidAngleUnit.SI);
94 }
95
96
97
98
99
100
101
102
103 public static FloatSolidAngle interpolate(final FloatSolidAngle zero, final FloatSolidAngle one, final float ratio)
104 {
105 Throw.when(ratio < 0.0 || ratio > 1.0, IllegalArgumentException.class,
106 "ratio for interpolation should be between 0 and 1, but is %f", ratio);
107 return new FloatSolidAngle(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
108 zero.getDisplayUnit());
109 }
110
111
112
113
114
115
116
117 public static FloatSolidAngle max(final FloatSolidAngle r1, final FloatSolidAngle r2)
118 {
119 return r1.gt(r2) ? r1 : r2;
120 }
121
122
123
124
125
126
127
128
129 public static FloatSolidAngle max(final FloatSolidAngle r1, final FloatSolidAngle r2, final FloatSolidAngle... rn)
130 {
131 FloatSolidAngle maxr = r1.gt(r2) ? r1 : r2;
132 for (FloatSolidAngle r : rn)
133 {
134 if (r.gt(maxr))
135 {
136 maxr = r;
137 }
138 }
139 return maxr;
140 }
141
142
143
144
145
146
147
148 public static FloatSolidAngle min(final FloatSolidAngle r1, final FloatSolidAngle r2)
149 {
150 return r1.lt(r2) ? r1 : r2;
151 }
152
153
154
155
156
157
158
159
160 public static FloatSolidAngle min(final FloatSolidAngle r1, final FloatSolidAngle r2, final FloatSolidAngle... rn)
161 {
162 FloatSolidAngle minr = r1.lt(r2) ? r1 : r2;
163 for (FloatSolidAngle r : rn)
164 {
165 if (r.lt(minr))
166 {
167 minr = r;
168 }
169 }
170 return minr;
171 }
172
173
174
175
176
177
178
179
180
181
182 public static FloatSolidAngle valueOf(final String text)
183 {
184 Throw.whenNull(text, "Error parsing FloatSolidAngle: text to parse is null");
185 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing FloatSolidAngle: empty text to parse");
186 try
187 {
188 NumberParser numberParser = new NumberParser().lenient().trailing();
189 float f = numberParser.parseFloat(text);
190 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
191 SolidAngleUnit unit = SolidAngleUnit.BASE.getUnitByAbbreviation(unitString);
192 Throw.when(unit == null, IllegalArgumentException.class, "Unit %s not found for quantity SolidAngle", unitString);
193 return new FloatSolidAngle(f, unit);
194 }
195 catch (Exception exception)
196 {
197 throw new IllegalArgumentException(
198 "Error parsing FloatSolidAngle from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
199 exception);
200 }
201 }
202
203
204
205
206
207
208
209
210
211 public static FloatSolidAngle of(final float value, final String unitString)
212 {
213 Throw.whenNull(unitString, "Error parsing FloatSolidAngle: unitString is null");
214 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing FloatSolidAngle: empty unitString");
215 SolidAngleUnit unit = SolidAngleUnit.BASE.getUnitByAbbreviation(unitString);
216 Throw.when(unit == null, IllegalArgumentException.class, "Error parsing FloatSolidAngle with unit %s", unitString);
217 return new FloatSolidAngle(value, unit);
218 }
219
220
221
222
223
224
225 public final FloatDimensionless divide(final FloatSolidAngle v)
226 {
227 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
228 }
229
230
231
232
233
234
235 public final FloatLuminousFlux times(final FloatLuminousIntensity v)
236 {
237 return new FloatLuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
238 }
239
240 @Override
241 public FloatSIScalar reciprocal()
242 {
243 return FloatSIScalar.divide(FloatDimensionless.ONE, this);
244 }
245
246
247
248
249
250
251
252 public static FloatSolidAngle multiply(final FloatScalarRel<?, ?> scalar1, final FloatScalarRel<?, ?> scalar2)
253 {
254 Throw.whenNull(scalar1, "scalar1 cannot be null");
255 Throw.whenNull(scalar2, "scalar2 cannot be null");
256 Throw.when(!scalar1.getDisplayUnit().getQuantity().getSiDimensions()
257 .plus(scalar2.getDisplayUnit().getQuantity().getSiDimensions()).equals(SolidAngleUnit.BASE.getSiDimensions()),
258 IllegalArgumentException.class, "Multiplying %s by %s does not result in instance of type FloatSolidAngle",
259 scalar1.toDisplayString(), scalar2.toDisplayString());
260 return new FloatSolidAngle(scalar1.si * scalar2.si, SolidAngleUnit.SI);
261 }
262
263
264
265
266
267
268
269 public static FloatSolidAngle divide(final FloatScalarRel<?, ?> scalar1, final FloatScalarRel<?, ?> scalar2)
270 {
271 Throw.whenNull(scalar1, "scalar1 cannot be null");
272 Throw.whenNull(scalar2, "scalar2 cannot be null");
273 Throw.when(!scalar1.getDisplayUnit().getQuantity().getSiDimensions()
274 .minus(scalar2.getDisplayUnit().getQuantity().getSiDimensions()).equals(SolidAngleUnit.BASE.getSiDimensions()),
275 IllegalArgumentException.class, "Dividing %s by %s does not result in an instance of type FloatSolidAngle",
276 scalar1.toDisplayString(), scalar2.toDisplayString());
277 return new FloatSolidAngle(scalar1.si / scalar2.si, SolidAngleUnit.SI);
278 }
279
280 }