1 package org.djunits.value.vfloat.scalar;
2
3 import org.djunits.unit.AngleSolidUnit;
4 import org.djunits.unit.DimensionlessUnit;
5
6 /**
7 * Easy access methods for the AngleSolid FloatScalar, which is relative by definition. An example is Speed. Instead of:
8 *
9 * <pre>
10 * FloatScalar.Rel<AngleSolidUnit> value = new FloatScalar.Rel<AngleSolidUnit>(100.0, AngleSolidUnit.SI);
11 * </pre>
12 *
13 * we can now write:
14 *
15 * <pre>
16 * FloatAngleSolid value = new FloatAngleSolid(100.0, AngleSolidUnit.SI);
17 * </pre>
18 *
19 * The compiler will automatically recognize which units belong to which quantity, and whether the quantity type and the unit
20 * used are compatible.
21 * <p>
22 * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
23 * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
24 * <p>
25 * $LastChangedDate: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, by $Author: averbraeck $,
26 * initial version Sep 5, 2015 <br>
27 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
28 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
29 */
30 public class FloatAngleSolid extends AbstractFloatScalarRel<AngleSolidUnit, FloatAngleSolid>
31 {
32 /** */
33 private static final long serialVersionUID = 20150901L;
34
35 /** constant with value zero. */
36 public static final FloatAngleSolid ZERO = new FloatAngleSolid(0.0f, AngleSolidUnit.SI);
37
38 /** constant with value NaN. */
39 @SuppressWarnings("checkstyle:constantname")
40 public static final FloatAngleSolid NaN = new FloatAngleSolid(Float.NaN, AngleSolidUnit.SI);
41
42 /** constant with value POSITIVE_INFINITY. */
43 public static final FloatAngleSolid POSITIVE_INFINITY = new FloatAngleSolid(Float.POSITIVE_INFINITY, AngleSolidUnit.SI);
44
45 /** constant with value NEGATIVE_INFINITY. */
46 public static final FloatAngleSolid NEGATIVE_INFINITY = new FloatAngleSolid(Float.NEGATIVE_INFINITY, AngleSolidUnit.SI);
47
48 /** constant with value MAX_VALUE. */
49 public static final FloatAngleSolid POS_MAXVALUE = new FloatAngleSolid(Float.MAX_VALUE, AngleSolidUnit.SI);
50
51 /** constant with value -MAX_VALUE. */
52 public static final FloatAngleSolid NEG_MAXVALUE = new FloatAngleSolid(-Float.MAX_VALUE, AngleSolidUnit.SI);
53
54 /**
55 * Construct FloatAngleSolid scalar.
56 * @param value float value
57 * @param unit unit for the float value
58 */
59 public FloatAngleSolid(final float value, final AngleSolidUnit unit)
60 {
61 super(value, unit);
62 }
63
64 /**
65 * Construct FloatAngleSolid scalar.
66 * @param value Scalar from which to construct this instance
67 */
68 public FloatAngleSolid(final FloatAngleSolid value)
69 {
70 super(value);
71 }
72
73 /**
74 * Construct FloatAngleSolid scalar using a double value.
75 * @param value double value
76 * @param unit unit for the resulting float value
77 */
78 public FloatAngleSolid(final double value, final AngleSolidUnit unit)
79 {
80 super((float) value, unit);
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public final FloatAngleSolid instantiateRel(final float value, final AngleSolidUnit unit)
86 {
87 return new FloatAngleSolid(value, unit);
88 }
89
90 /**
91 * Construct FloatAngleSolid scalar.
92 * @param value float value in SI units
93 * @return the new scalar with the SI value
94 */
95 public static final FloatAngleSolid createSI(final float value)
96 {
97 return new FloatAngleSolid(value, AngleSolidUnit.SI);
98 }
99
100 /**
101 * Interpolate between two values.
102 * @param zero the low value
103 * @param one the high value
104 * @param ratio the ratio between 0 and 1, inclusive
105 * @return a Scalar at the ratio between
106 */
107 public static FloatAngleSolid interpolate(final FloatAngleSolid zero, final FloatAngleSolid one, final float ratio)
108 {
109 return new FloatAngleSolid(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getUnit()) * ratio, zero.getUnit());
110 }
111
112 /**
113 * Return the maximum value of two relative scalars.
114 * @param r1 the first scalar
115 * @param r2 the second scalar
116 * @return the maximum value of two relative scalars
117 */
118 public static FloatAngleSolid max(final FloatAngleSolid r1, final FloatAngleSolid r2)
119 {
120 return (r1.gt(r2)) ? r1 : r2;
121 }
122
123 /**
124 * Return the maximum value of more than two relative scalars.
125 * @param r1 the first scalar
126 * @param r2 the second scalar
127 * @param rn the other scalars
128 * @return the maximum value of more than two relative scalars
129 */
130 public static FloatAngleSolid max(final FloatAngleSolid r1, final FloatAngleSolid r2, final FloatAngleSolid... rn)
131 {
132 FloatAngleSolid maxr = (r1.gt(r2)) ? r1 : r2;
133 for (FloatAngleSolid r : rn)
134 {
135 if (r.gt(maxr))
136 {
137 maxr = r;
138 }
139 }
140 return maxr;
141 }
142
143 /**
144 * Return the minimum value of two relative scalars.
145 * @param r1 the first scalar
146 * @param r2 the second scalar
147 * @return the minimum value of two relative scalars
148 */
149 public static FloatAngleSolid min(final FloatAngleSolid r1, final FloatAngleSolid r2)
150 {
151 return (r1.lt(r2)) ? r1 : r2;
152 }
153
154 /**
155 * Return the minimum value of more than two relative scalars.
156 * @param r1 the first scalar
157 * @param r2 the second scalar
158 * @param rn the other scalars
159 * @return the minimum value of more than two relative scalars
160 */
161 public static FloatAngleSolid min(final FloatAngleSolid r1, final FloatAngleSolid r2, final FloatAngleSolid... rn)
162 {
163 FloatAngleSolid minr = (r1.lt(r2)) ? r1 : r2;
164 for (FloatAngleSolid r : rn)
165 {
166 if (r.lt(minr))
167 {
168 minr = r;
169 }
170 }
171 return minr;
172 }
173
174 /**
175 * Calculate the division of FloatAngleSolid and FloatAngleSolid, which results in a FloatDimensionless scalar.
176 * @param v FloatAngleSolid scalar
177 * @return FloatDimensionless scalar as a division of FloatAngleSolid and FloatAngleSolid
178 */
179 public final FloatDimensionless divideBy(final FloatAngleSolid v)
180 {
181 return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
182 }
183
184 }