View Javadoc
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.DimensionlessUnit;
9   import org.djunits.unit.LuminousFluxUnit;
10  import org.djunits.unit.SolidAngleUnit;
11  import org.djunits.value.util.ValueUtil;
12  import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
13  
14  /**
15   * Easy access methods for the SolidAngle DoubleScalar, which is relative by definition.
16   * <p>
17   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
19   * </p>
20   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
22   */
23  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
24  public class SolidAngle extends AbstractDoubleScalarRel<SolidAngleUnit, SolidAngle>
25  {
26      /** */
27      private static final long serialVersionUID = 20150905L;
28  
29      /** Constant with value zero. */
30      public static final SolidAnglecalar/SolidAngle.html#SolidAngle">SolidAngle ZERO = new SolidAngle(0.0, SolidAngleUnit.SI);
31  
32      /** Constant with value one. */
33      public static final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle ONE = new SolidAngle(1.0, SolidAngleUnit.SI);
34  
35      /** Constant with value NaN. */
36      @SuppressWarnings("checkstyle:constantname")
37      public static final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle NaN = new SolidAngle(Double.NaN, SolidAngleUnit.SI);
38  
39      /** Constant with value POSITIVE_INFINITY. */
40      public static final SolidAnglegle.html#SolidAngle">SolidAngle POSITIVE_INFINITY = new SolidAngle(Double.POSITIVE_INFINITY, SolidAngleUnit.SI);
41  
42      /** Constant with value NEGATIVE_INFINITY. */
43      public static final SolidAnglegle.html#SolidAngle">SolidAngle NEGATIVE_INFINITY = new SolidAngle(Double.NEGATIVE_INFINITY, SolidAngleUnit.SI);
44  
45      /** Constant with value MAX_VALUE. */
46      public static final SolidAnglelidAngle.html#SolidAngle">SolidAngle POS_MAXVALUE = new SolidAngle(Double.MAX_VALUE, SolidAngleUnit.SI);
47  
48      /** Constant with value -MAX_VALUE. */
49      public static final SolidAnglelidAngle.html#SolidAngle">SolidAngle NEG_MAXVALUE = new SolidAngle(-Double.MAX_VALUE, SolidAngleUnit.SI);
50  
51      /**
52       * Construct SolidAngle scalar.
53       * @param value double; the double value
54       * @param unit SolidAngleUnit; unit for the double value
55       */
56      public SolidAngle(final double value, final SolidAngleUnit unit)
57      {
58          super(value, unit);
59      }
60  
61      /**
62       * Construct SolidAngle scalar.
63       * @param value SolidAngle; Scalar from which to construct this instance
64       */
65      public SolidAngleble/scalar/SolidAngle.html#SolidAngle">SolidAngle(final SolidAngle value)
66      {
67          super(value);
68      }
69  
70      /** {@inheritDoc} */
71      @Override
72      public final SolidAngle instantiateRel(final double value, final SolidAngleUnit unit)
73      {
74          return new SolidAngle(value, unit);
75      }
76  
77      /**
78       * Construct SolidAngle scalar.
79       * @param value double; the double value in SI units
80       * @return SolidAngle; the new scalar with the SI value
81       */
82      public static final SolidAngle instantiateSI(final double value)
83      {
84          return new SolidAngle(value, SolidAngleUnit.SI);
85      }
86  
87      /**
88       * Interpolate between two values.
89       * @param zero SolidAngle; the low value
90       * @param one SolidAngle; the high value
91       * @param ratio double; the ratio between 0 and 1, inclusive
92       * @return SolidAngle; a Scalar at the ratio between
93       */
94      public static SolidAnglealar/SolidAngle.html#SolidAngle">SolidAngleolidAngle.html#SolidAngle">SolidAngle interpolate(final SolidAnglealar/SolidAngle.html#SolidAngle">SolidAngle zero, final SolidAngle one, final double ratio)
95      {
96          return new SolidAngle(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
97                  zero.getDisplayUnit());
98      }
99  
100     /**
101      * Return the maximum value of two relative scalars.
102      * @param r1 SolidAngle; the first scalar
103      * @param r2 SolidAngle; the second scalar
104      * @return SolidAngle; the maximum value of two relative scalars
105      */
106     public static SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle max(final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle r1, final SolidAngle r2)
107     {
108         return r1.gt(r2) ? r1 : r2;
109     }
110 
111     /**
112      * Return the maximum value of more than two relative scalars.
113      * @param r1 SolidAngle; the first scalar
114      * @param r2 SolidAngle; the second scalar
115      * @param rn SolidAngle...; the other scalars
116      * @return SolidAngle; the maximum value of more than two relative scalars
117      */
118     public static SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle max(final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle r1, final SolidAngle r2, final SolidAngle... rn)
119     {
120         SolidAngle maxr = r1.gt(r2) ? r1 : r2;
121         for (SolidAngle r : rn)
122         {
123             if (r.gt(maxr))
124             {
125                 maxr = r;
126             }
127         }
128         return maxr;
129     }
130 
131     /**
132      * Return the minimum value of two relative scalars.
133      * @param r1 SolidAngle; the first scalar
134      * @param r2 SolidAngle; the second scalar
135      * @return SolidAngle; the minimum value of two relative scalars
136      */
137     public static SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle min(final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle r1, final SolidAngle r2)
138     {
139         return r1.lt(r2) ? r1 : r2;
140     }
141 
142     /**
143      * Return the minimum value of more than two relative scalars.
144      * @param r1 SolidAngle; the first scalar
145      * @param r2 SolidAngle; the second scalar
146      * @param rn SolidAngle...; the other scalars
147      * @return SolidAngle; the minimum value of more than two relative scalars
148      */
149     public static SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle min(final SolidAnglescalar/SolidAngle.html#SolidAngle">SolidAngle r1, final SolidAngle r2, final SolidAngle... rn)
150     {
151         SolidAngle minr = r1.lt(r2) ? r1 : r2;
152         for (SolidAngle r : rn)
153         {
154             if (r.lt(minr))
155             {
156                 minr = r;
157             }
158         }
159         return minr;
160     }
161 
162     /**
163      * Returns a SolidAngle representation of a textual representation of a value with a unit. The String representation that
164      * can be parsed is the double value in the unit, followed by the official abbreviation of the unit. Spaces are allowed, but
165      * not required, between the value and the unit.
166      * @param text String; the textual representation to parse into a SolidAngle
167      * @return SolidAngle; the Scalar representation of the value in its unit
168      * @throws IllegalArgumentException when the text cannot be parsed
169      * @throws NullPointerException when the text argument is null
170      */
171     public static SolidAngle valueOf(final String text)
172     {
173         Throw.whenNull(text, "Error parsing SolidAngle: text to parse is null");
174         Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing SolidAngle: empty text to parse");
175         Matcher matcher = ValueUtil.NUMBER_PATTERN.matcher(text);
176         if (matcher.find())
177         {
178             int index = matcher.end();
179             String unitString = text.substring(index).trim();
180             String valueString = text.substring(0, index).trim();
181             SolidAngleUnit unit = SolidAngleUnit.BASE.getUnitByAbbreviation(unitString);
182             if (unit != null)
183             {
184                 double d = Double.parseDouble(valueString);
185                 return new SolidAngle(d, unit);
186             }
187         }
188         throw new IllegalArgumentException("Error parsing SolidAngle from " + text);
189     }
190 
191     /**
192      * Returns a SolidAngle based on a value and the textual representation of the unit.
193      * @param value double; the value to use
194      * @param unitString String; the textual representation of the unit
195      * @return SolidAngle; the Scalar representation of the value in its unit
196      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
197      * @throws NullPointerException when the unitString argument is null
198      */
199     public static SolidAngle of(final double value, final String unitString)
200     {
201         Throw.whenNull(unitString, "Error parsing SolidAngle: unitString is null");
202         Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing SolidAngle: empty unitString");
203         SolidAngleUnit unit = SolidAngleUnit.BASE.getUnitByAbbreviation(unitString);
204         if (unit != null)
205         {
206             return new SolidAngle(value, unit);
207         }
208         throw new IllegalArgumentException("Error parsing SolidAngle with unit " + unitString);
209     }
210 
211     /**
212      * Calculate the division of SolidAngle and SolidAngle, which results in a Dimensionless scalar.
213      * @param v SolidAngle scalar
214      * @return Dimensionless scalar as a division of SolidAngle and SolidAngle
215      */
216     public final Dimensionless divide(final SolidAngle v)
217     {
218         return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
219     }
220 
221     /**
222      * Calculate the multiplication of SolidAngle and LuminousIntensity, which results in a LuminousFlux scalar.
223      * @param v SolidAngle scalar
224      * @return LuminousFlux scalar as a multiplication of SolidAngle and LuminousIntensity
225      */
226     public final LuminousFlux times(final LuminousIntensity v)
227     {
228         return new LuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
229     }
230 
231 }