1 package org.djunits.value.vfloat.scalar;
2
3 import java.util.regex.Matcher;
4
5 import org.djunits.unit.AngleSolidUnit;
6 import org.djunits.unit.DimensionlessUnit;
7 import org.djunits.unit.Unit;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 public class FloatAngleSolid extends AbstractFloatScalarRel<AngleSolidUnit, FloatAngleSolid>
34 {
35
36 private static final long serialVersionUID = 20150901L;
37
38
39 public static final FloatAngleSolid ZERO = new FloatAngleSolid(0.0f, AngleSolidUnit.SI);
40
41
42 @SuppressWarnings("checkstyle:constantname")
43 public static final FloatAngleSolid NaN = new FloatAngleSolid(Float.NaN, AngleSolidUnit.SI);
44
45
46 public static final FloatAngleSolid POSITIVE_INFINITY = new FloatAngleSolid(Float.POSITIVE_INFINITY, AngleSolidUnit.SI);
47
48
49 public static final FloatAngleSolid NEGATIVE_INFINITY = new FloatAngleSolid(Float.NEGATIVE_INFINITY, AngleSolidUnit.SI);
50
51
52 public static final FloatAngleSolid POS_MAXVALUE = new FloatAngleSolid(Float.MAX_VALUE, AngleSolidUnit.SI);
53
54
55 public static final FloatAngleSolid NEG_MAXVALUE = new FloatAngleSolid(-Float.MAX_VALUE, AngleSolidUnit.SI);
56
57
58
59
60
61
62 public FloatAngleSolid(final float value, final AngleSolidUnit unit)
63 {
64 super(value, unit);
65 }
66
67
68
69
70
71 public FloatAngleSolid(final FloatAngleSolid value)
72 {
73 super(value);
74 }
75
76
77
78
79
80
81 public FloatAngleSolid(final double value, final AngleSolidUnit unit)
82 {
83 super((float) value, unit);
84 }
85
86
87 @Override
88 public final FloatAngleSolid instantiateRel(final float value, final AngleSolidUnit unit)
89 {
90 return new FloatAngleSolid(value, unit);
91 }
92
93
94
95
96
97
98 public static final FloatAngleSolid createSI(final float value)
99 {
100 return new FloatAngleSolid(value, AngleSolidUnit.SI);
101 }
102
103
104
105
106
107
108
109
110 public static FloatAngleSolid interpolate(final FloatAngleSolid zero, final FloatAngleSolid one, final float ratio)
111 {
112 return new FloatAngleSolid(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getUnit()) * ratio, zero.getUnit());
113 }
114
115
116
117
118
119
120
121 public static FloatAngleSolid max(final FloatAngleSolid r1, final FloatAngleSolid r2)
122 {
123 return (r1.gt(r2)) ? r1 : r2;
124 }
125
126
127
128
129
130
131
132
133 public static FloatAngleSolid max(final FloatAngleSolid r1, final FloatAngleSolid r2, final FloatAngleSolid... rn)
134 {
135 FloatAngleSolid maxr = (r1.gt(r2)) ? r1 : r2;
136 for (FloatAngleSolid r : rn)
137 {
138 if (r.gt(maxr))
139 {
140 maxr = r;
141 }
142 }
143 return maxr;
144 }
145
146
147
148
149
150
151
152 public static FloatAngleSolid min(final FloatAngleSolid r1, final FloatAngleSolid r2)
153 {
154 return (r1.lt(r2)) ? r1 : r2;
155 }
156
157
158
159
160
161
162
163
164 public static FloatAngleSolid min(final FloatAngleSolid r1, final FloatAngleSolid r2, final FloatAngleSolid... rn)
165 {
166 FloatAngleSolid minr = (r1.lt(r2)) ? r1 : r2;
167 for (FloatAngleSolid r : rn)
168 {
169 if (r.lt(minr))
170 {
171 minr = r;
172 }
173 }
174 return minr;
175 }
176
177
178
179
180
181
182
183
184
185 public static FloatAngleSolid valueOf(final String text) throws IllegalArgumentException
186 {
187 if (text == null || text.length() == 0)
188 {
189 throw new IllegalArgumentException("Error parsing FloatAngleSolid -- null or empty argument");
190 }
191 Matcher matcher = NUMBER_PATTERN.matcher(text);
192 if (matcher.find())
193 {
194 int index = matcher.end();
195 try
196 {
197 String unitString = text.substring(index).trim();
198 String valueString = text.substring(0, index).trim();
199 for (AngleSolidUnit unit : Unit.getUnits(AngleSolidUnit.class))
200 {
201 if (unit.getDefaultLocaleTextualRepresentations().contains(unitString))
202 {
203 float f = Float.parseFloat(valueString);
204 return new FloatAngleSolid(f, unit);
205 }
206 }
207 }
208 catch (Exception exception)
209 {
210 throw new IllegalArgumentException("Error parsing FloatAngleSolid from " + text, exception);
211 }
212 }
213 throw new IllegalArgumentException("Error parsing FloatAngleSolid from " + text);
214 }
215
216
217
218
219
220
221 public final FloatDimensionless divideBy(final FloatAngleSolid v)
222 {
223 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
224 }
225
226 }