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