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