1 package org.djunits.value.vdouble.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.LuminousIntensityUnit;
8 import org.djunits.value.vdouble.scalar.base.DoubleScalar;
9 import org.djunits.value.vdouble.scalar.base.DoubleScalarRel;
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 LuminousIntensity extends DoubleScalarRel<LuminousIntensityUnit, LuminousIntensity>
26 {
27
28 private static final long serialVersionUID = 20150905L;
29
30
31 public static final LuminousIntensity ZERO = new LuminousIntensity(0.0, LuminousIntensityUnit.SI);
32
33
34 public static final LuminousIntensity ONE = new LuminousIntensity(1.0, LuminousIntensityUnit.SI);
35
36
37 @SuppressWarnings("checkstyle:constantname")
38 public static final LuminousIntensity NaN = new LuminousIntensity(Double.NaN, LuminousIntensityUnit.SI);
39
40
41 public static final LuminousIntensity POSITIVE_INFINITY =
42 new LuminousIntensity(Double.POSITIVE_INFINITY, LuminousIntensityUnit.SI);
43
44
45 public static final LuminousIntensity NEGATIVE_INFINITY =
46 new LuminousIntensity(Double.NEGATIVE_INFINITY, LuminousIntensityUnit.SI);
47
48
49 public static final LuminousIntensity POS_MAXVALUE = new LuminousIntensity(Double.MAX_VALUE, LuminousIntensityUnit.SI);
50
51
52 public static final LuminousIntensity NEG_MAXVALUE = new LuminousIntensity(-Double.MAX_VALUE, LuminousIntensityUnit.SI);
53
54
55
56
57
58
59 public LuminousIntensity(final double value, final LuminousIntensityUnit unit)
60 {
61 super(value, unit);
62 }
63
64
65
66
67
68 public LuminousIntensity(final LuminousIntensity value)
69 {
70 super(value);
71 }
72
73 @Override
74 public final LuminousIntensity instantiateRel(final double value, final LuminousIntensityUnit unit)
75 {
76 return new LuminousIntensity(value, unit);
77 }
78
79
80
81
82
83
84 public static final LuminousIntensity instantiateSI(final double value)
85 {
86 return new LuminousIntensity(value, LuminousIntensityUnit.SI);
87 }
88
89
90
91
92
93
94
95
96 public static LuminousIntensity interpolate(final LuminousIntensity zero, final LuminousIntensity one, final double ratio)
97 {
98 return new LuminousIntensity(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
99 zero.getDisplayUnit());
100 }
101
102
103
104
105
106
107
108 public static LuminousIntensity max(final LuminousIntensity r1, final LuminousIntensity r2)
109 {
110 return r1.gt(r2) ? r1 : r2;
111 }
112
113
114
115
116
117
118
119
120 public static LuminousIntensity max(final LuminousIntensity r1, final LuminousIntensity r2, final LuminousIntensity... rn)
121 {
122 LuminousIntensity maxr = r1.gt(r2) ? r1 : r2;
123 for (LuminousIntensity r : rn)
124 {
125 if (r.gt(maxr))
126 {
127 maxr = r;
128 }
129 }
130 return maxr;
131 }
132
133
134
135
136
137
138
139 public static LuminousIntensity min(final LuminousIntensity r1, final LuminousIntensity r2)
140 {
141 return r1.lt(r2) ? r1 : r2;
142 }
143
144
145
146
147
148
149
150
151 public static LuminousIntensity min(final LuminousIntensity r1, final LuminousIntensity r2, final LuminousIntensity... rn)
152 {
153 LuminousIntensity minr = r1.lt(r2) ? r1 : r2;
154 for (LuminousIntensity r : rn)
155 {
156 if (r.lt(minr))
157 {
158 minr = r;
159 }
160 }
161 return minr;
162 }
163
164
165
166
167
168
169
170
171
172
173 public static LuminousIntensity valueOf(final String text)
174 {
175 Throw.whenNull(text, "Error parsing LuminousIntensity: text to parse is null");
176 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing LuminousIntensity: empty text to parse");
177 try
178 {
179 NumberParser numberParser = new NumberParser().lenient().trailing();
180 double d = numberParser.parseDouble(text);
181 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
182 LuminousIntensityUnit unit = LuminousIntensityUnit.BASE.getUnitByAbbreviation(unitString);
183 if (unit == null)
184 throw new IllegalArgumentException("Unit " + unitString + " not found");
185 return new LuminousIntensity(d, unit);
186 }
187 catch (Exception exception)
188 {
189 throw new IllegalArgumentException("Error parsing LuminousIntensity from " + text + " using Locale "
190 + Locale.getDefault(Locale.Category.FORMAT), exception);
191 }
192 }
193
194
195
196
197
198
199
200
201
202 public static LuminousIntensity of(final double value, final String unitString)
203 {
204 Throw.whenNull(unitString, "Error parsing LuminousIntensity: unitString is null");
205 Throw.when(unitString.length() == 0, IllegalArgumentException.class,
206 "Error parsing LuminousIntensity: empty unitString");
207 LuminousIntensityUnit unit = LuminousIntensityUnit.BASE.getUnitByAbbreviation(unitString);
208 if (unit != null)
209 {
210 return new LuminousIntensity(value, unit);
211 }
212 throw new IllegalArgumentException("Error parsing LuminousIntensity with unit " + unitString);
213 }
214
215
216
217
218
219
220 public final Dimensionless divide(final LuminousIntensity v)
221 {
222 return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
223 }
224
225
226
227
228
229
230 public final LuminousFlux times(final SolidAngle v)
231 {
232 return new LuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
233 }
234
235 @Override
236 public SIScalar reciprocal()
237 {
238 return DoubleScalar.divide(Dimensionless.ONE, this);
239 }
240
241 }