View Javadoc
1   package org.djunits.unit;
2   
3   import org.djunits.unit.quantity.Quantity;
4   import org.djunits.unit.scale.IdentityScale;
5   import org.djunits.unit.si.SIPrefixes;
6   import org.djunits.unit.unitsystem.UnitSystem;
7   
8   /**
9    * The units of force.
10   * <p>
11   * Copyright (c) 2015-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
13   * <p>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   */
16  public class ForceUnit extends Unit<ForceUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The base, with "kgm/s2" as the SI signature. */
22      public static final Quantity<ForceUnit> BASE = new Quantity<>("Force", "kgm/s2");
23  
24      /** The SI unit for force is Newton. */
25      public static final ForceUnit SI =
26              new ForceUnit().build(new Unit.Builder<ForceUnit>().setQuantity(BASE).setId("N").setName("newton")
27                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.NONE, 1.0).setScale(IdentityScale.SCALE));
28  
29      /** Newton. */
30      public static final ForceUnit NEWTON = SI;
31  
32      /** Dyne. */
33      public static final ForceUnit DYNE =
34              SI.deriveLinear(factorMA(MassUnit.GRAM, AccelerationUnit.GAL), "dyn", "dyne", UnitSystem.CGS);
35  
36      /** kilogram-force. */
37      public static final ForceUnit KILOGRAM_FORCE = SI.deriveLinear(
38              factorMA(MassUnit.KILOGRAM, AccelerationUnit.STANDARD_GRAVITY), "kgf", "kilogram-force", UnitSystem.OTHER);
39  
40      /** ounce-force. */
41      public static final ForceUnit OUNCE_FORCE = SI.deriveLinear(factorMA(MassUnit.OUNCE, AccelerationUnit.STANDARD_GRAVITY),
42              "ozf", "ounce-force", UnitSystem.IMPERIAL);
43  
44      /** pound-force. */
45      public static final ForceUnit POUND_FORCE = SI.deriveLinear(factorMA(MassUnit.POUND, AccelerationUnit.STANDARD_GRAVITY),
46              "lbf", "pound-force", UnitSystem.IMPERIAL);
47  
48      /** ton-force. */
49      public static final ForceUnit TON_FORCE = SI.deriveLinear(factorMA(MassUnit.TON_SHORT, AccelerationUnit.STANDARD_GRAVITY),
50              "tnf", "ton-force", UnitSystem.IMPERIAL);
51  
52      /** sthene. */
53      public static final ForceUnit STHENE =
54              SI.deriveLinear(factorMA(MassUnit.TON_METRIC, AccelerationUnit.METER_PER_SECOND_2), "sn", "sthene", UnitSystem.MTS);
55  
56      /**
57       * Determine the conversion factor to the base force unit, given a mass unit and an acceleration unit.
58       * @param mass MassUnit; the used mass unit, e.g. lb
59       * @param acceleration AccelerationUnit; the used acceleration unit, e.g. ft/s2
60       * @return double; the conversion factor from the provided units (e.g. lb.ft/s2) to the standard unit (e.g., kg.m/s2)
61       */
62      private static double factorMA(final MassUnit mass, final AccelerationUnit acceleration)
63      {
64          return mass.getScale().toStandardUnit(1.0) * acceleration.getScale().toStandardUnit(1.0);
65      }
66  
67  }