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.FloatScalar;
9 import org.djunits.value.vfloat.scalar.base.FloatScalarRel;
10 import org.djutils.base.NumberParser;
11 import org.djutils.exceptions.Throw;
12
13 import jakarta.annotation.Generated;
14
15
16
17
18
19
20
21
22
23
24 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
25 public class FloatSolidAngle extends FloatScalarRel<SolidAngleUnit, FloatSolidAngle>
26 {
27
28 private static final long serialVersionUID = 20150901L;
29
30
31 public static final FloatSolidAngle ZERO = new FloatSolidAngle(0.0f, SolidAngleUnit.SI);
32
33
34 public static final FloatSolidAngle ONE = new FloatSolidAngle(1.0f, SolidAngleUnit.SI);
35
36
37 @SuppressWarnings("checkstyle:constantname")
38 public static final FloatSolidAngle NaN = new FloatSolidAngle(Float.NaN, SolidAngleUnit.SI);
39
40
41 public static final FloatSolidAngle POSITIVE_INFINITY = new FloatSolidAngle(Float.POSITIVE_INFINITY, SolidAngleUnit.SI);
42
43
44 public static final FloatSolidAngle NEGATIVE_INFINITY = new FloatSolidAngle(Float.NEGATIVE_INFINITY, SolidAngleUnit.SI);
45
46
47 public static final FloatSolidAngle POS_MAXVALUE = new FloatSolidAngle(Float.MAX_VALUE, SolidAngleUnit.SI);
48
49
50 public static final FloatSolidAngle NEG_MAXVALUE = new FloatSolidAngle(-Float.MAX_VALUE, SolidAngleUnit.SI);
51
52
53
54
55
56
57 public FloatSolidAngle(final float value, final SolidAngleUnit unit)
58 {
59 super(value, unit);
60 }
61
62
63
64
65
66 public FloatSolidAngle(final FloatSolidAngle value)
67 {
68 super(value);
69 }
70
71
72
73
74
75
76 public FloatSolidAngle(final double value, final SolidAngleUnit unit)
77 {
78 super((float) value, unit);
79 }
80
81
82 @Override
83 public final FloatSolidAngle instantiateRel(final float value, final SolidAngleUnit unit)
84 {
85 return new FloatSolidAngle(value, unit);
86 }
87
88
89
90
91
92
93 public static final FloatSolidAngle instantiateSI(final float value)
94 {
95 return new FloatSolidAngle(value, SolidAngleUnit.SI);
96 }
97
98
99
100
101
102
103
104
105 public static FloatSolidAngle interpolate(final FloatSolidAngle zero, final FloatSolidAngle one, final float ratio)
106 {
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 if (unit == null)
193 throw new IllegalArgumentException("Unit " + unitString + " not found");
194 return new FloatSolidAngle(f, unit);
195 }
196 catch (Exception exception)
197 {
198 throw new IllegalArgumentException(
199 "Error parsing FloatSolidAngle from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
200 exception);
201 }
202 }
203
204
205
206
207
208
209
210
211
212 public static FloatSolidAngle of(final float value, final String unitString)
213 {
214 Throw.whenNull(unitString, "Error parsing FloatSolidAngle: unitString is null");
215 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing FloatSolidAngle: empty unitString");
216 SolidAngleUnit unit = SolidAngleUnit.BASE.getUnitByAbbreviation(unitString);
217 if (unit != null)
218 {
219 return new FloatSolidAngle(value, unit);
220 }
221 throw new IllegalArgumentException("Error parsing FloatSolidAngle with unit " + unitString);
222 }
223
224
225
226
227
228
229 public final FloatDimensionless divide(final FloatSolidAngle v)
230 {
231 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
232 }
233
234
235
236
237
238
239 public final FloatLuminousFlux times(final FloatLuminousIntensity v)
240 {
241 return new FloatLuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
242 }
243
244
245 @Override
246 public FloatSIScalar reciprocal()
247 {
248 return FloatScalar.divide(FloatDimensionless.ONE, this);
249 }
250
251 }