1 package org.djunits.value.vdouble.scalar;
2
3 import java.util.regex.Matcher;
4
5 import javax.annotation.Generated;
6
7 import org.djunits.Throw;
8 import org.djunits.unit.AngleUnit;
9 import org.djunits.unit.AngularVelocityUnit;
10 import org.djunits.unit.DimensionlessUnit;
11 import org.djunits.unit.DirectionUnit;
12 import org.djunits.unit.DurationUnit;
13 import org.djunits.value.util.ValueUtil;
14 import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRelWithAbs;
15
16
17
18
19
20
21
22
23
24
25
26 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
27 public class Angle extends AbstractDoubleScalarRelWithAbs<DirectionUnit, Direction, AngleUnit, Angle>
28 {
29
30 private static final long serialVersionUID = 20150901L;
31
32
33 public static final Angleble/scalar/Angle.html#Angle">Angle ZERO = new Angle(0.0, AngleUnit.SI);
34
35
36 public static final Angleuble/scalar/Angle.html#Angle">Angle ONE = new Angle(1.0, AngleUnit.SI);
37
38
39 @SuppressWarnings("checkstyle:constantname")
40 public static final Angleuble/scalar/Angle.html#Angle">Angle NaN = new Angle(Double.NaN, AngleUnit.SI);
41
42
43 public static final Anglegle.html#Angle">Angle POSITIVE_INFINITY = new Angle(Double.POSITIVE_INFINITY, AngleUnit.SI);
44
45
46 public static final Anglegle.html#Angle">Angle NEGATIVE_INFINITY = new Angle(Double.NEGATIVE_INFINITY, AngleUnit.SI);
47
48
49 public static final Anglear/Angle.html#Angle">Angle POS_MAXVALUE = new Angle(Double.MAX_VALUE, AngleUnit.SI);
50
51
52 public static final Anglear/Angle.html#Angle">Angle NEG_MAXVALUE = new Angle(-Double.MAX_VALUE, AngleUnit.SI);
53
54
55
56
57
58
59 public Angle(final double value, final AngleUnit unit)
60 {
61 super(value, unit);
62 }
63
64
65
66
67
68 public Angle/vdouble/scalar/Angle.html#Angle">Angle(final Angle value)
69 {
70 super(value);
71 }
72
73
74 @Override
75 public final Angle instantiateRel(final double value, final AngleUnit unit)
76 {
77 return new Angle(value, unit);
78 }
79
80
81 @Override
82 public final Direction instantiateAbs(final double value, final DirectionUnit unit)
83 {
84 return new Direction(value, unit);
85 }
86
87
88
89
90
91
92 public static final Angle instantiateSI(final double value)
93 {
94 return new Angle(value, AngleUnit.SI);
95 }
96
97
98
99
100
101
102
103
104 public static Anglele/scalar/Angle.html#Angle">Anglelar/Angle.html#Angle">Angle interpolate(final Anglele/scalar/Angle.html#Angle">Angle zero, final Angle one, final double ratio)
105 {
106 return new Angle(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio, zero.getDisplayUnit());
107 }
108
109
110
111
112
113
114
115 public static Angleuble/scalar/Angle.html#Angle">Angleuble/scalar/Angle.html#Angle">Angle max(final Angleuble/scalar/Angle.html#Angle">Angle r1, final Angle r2)
116 {
117 return r1.gt(r2) ? r1 : r2;
118 }
119
120
121
122
123
124
125
126
127 public static Angleuble/scalar/Angle.html#Angle">Angleuble/scalar/Angle.html#Angle">Angle max(final Angleuble/scalar/Angle.html#Angle">Angle r1, final Angle r2, final Angle... rn)
128 {
129 Angle maxr = r1.gt(r2) ? r1 : r2;
130 for (Angle r : rn)
131 {
132 if (r.gt(maxr))
133 {
134 maxr = r;
135 }
136 }
137 return maxr;
138 }
139
140
141
142
143
144
145
146 public static Angleuble/scalar/Angle.html#Angle">Angleuble/scalar/Angle.html#Angle">Angle min(final Angleuble/scalar/Angle.html#Angle">Angle r1, final Angle r2)
147 {
148 return r1.lt(r2) ? r1 : r2;
149 }
150
151
152
153
154
155
156
157
158 public static Angleuble/scalar/Angle.html#Angle">Angleuble/scalar/Angle.html#Angle">Angle min(final Angleuble/scalar/Angle.html#Angle">Angle r1, final Angle r2, final Angle... rn)
159 {
160 Angle minr = r1.lt(r2) ? r1 : r2;
161 for (Angle r : rn)
162 {
163 if (r.lt(minr))
164 {
165 minr = r;
166 }
167 }
168 return minr;
169 }
170
171
172
173
174
175
176
177
178
179
180 public static Angle valueOf(final String text)
181 {
182 Throw.whenNull(text, "Error parsing Angle: text to parse is null");
183 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing Angle: empty text to parse");
184 Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
185 if (matcher.find())
186 {
187 int index = matcher.end();
188 String unitString = text.substring(index).trim();
189 String valueString = text.substring(0, index).trim();
190 AngleUnit unit = AngleUnit.BASE.getUnitByAbbreviation(unitString);
191 if (unit != null)
192 {
193 double d = Double.parseDouble(valueString);
194 return new Angle(d, unit);
195 }
196 }
197 throw new IllegalArgumentException("Error parsing Angle from " + text);
198 }
199
200
201
202
203
204
205
206
207
208 public static Angle of(final double value, final String unitString)
209 {
210 Throw.whenNull(unitString, "Error parsing Angle: unitString is null");
211 Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing Angle: empty unitString");
212 AngleUnit unit = AngleUnit.BASE.getUnitByAbbreviation(unitString);
213 if (unit != null)
214 {
215 return new Angle(value, unit);
216 }
217 throw new IllegalArgumentException("Error parsing Angle with unit " + unitString);
218 }
219
220
221
222
223
224
225 public final Dimensionless divide(final Angle v)
226 {
227 return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
228 }
229
230
231
232
233
234
235 public final AngularVelocity times(final Frequency v)
236 {
237 return new AngularVelocity(this.si * v.si, AngularVelocityUnit.SI);
238 }
239
240
241
242
243
244
245 public final AngularVelocity divide(final Duration v)
246 {
247 return new AngularVelocity(this.si / v.si, AngularVelocityUnit.SI);
248 }
249
250
251
252
253
254
255 public final Duration divide(final AngularVelocity v)
256 {
257 return new Duration(this.si / v.si, DurationUnit.SI);
258 }
259
260 }