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 torque (moment 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 TorqueUnit extends Unit<TorqueUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The base, with "kgm2/s2" as the SI signature. */
22      public static final Quantity<TorqueUnit> BASE = new Quantity<>("Torque", "kgm2/s2");
23  
24      /** The SI unit for torque is Newton meter = kgm2/s2. */
25      public static final TorqueUnit SI =
26              new TorqueUnit().build(new Unit.Builder<TorqueUnit>().setQuantity(BASE).setId("N.m").setName("Newton meter")
27                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.NONE, 1.0).setScale(IdentityScale.SCALE));
28  
29      /** Newton meter. */
30      public static final TorqueUnit NEWTON_METER = SI;
31  
32      /** meter kilogram-force. */
33      public static final TorqueUnit METER_KILOGRAM_FORCE = SI.deriveLinear(factorLF(LengthUnit.METER, ForceUnit.KILOGRAM_FORCE),
34              "m.kgf", "meter kilogram-force", UnitSystem.OTHER);
35  
36      /** Pound foot. */
37      public static final TorqueUnit POUND_FOOT =
38              SI.deriveLinear(factorLF(LengthUnit.FOOT, ForceUnit.POUND_FORCE), "lbf.ft", "pound-foot", UnitSystem.IMPERIAL);
39  
40      /** Pound inch. */
41      public static final TorqueUnit POUND_INCH =
42              SI.deriveLinear(factorLF(LengthUnit.INCH, ForceUnit.POUND_FORCE), "lbf.in", "pound-inch", UnitSystem.IMPERIAL);
43  
44      /**
45       * Determine the conversion factor to the base torque unit, given a length unit and a force unit.
46       * @param length LengthUnit; the used length unit, e.g. m
47       * @param force ForceUnit; the used force unit, e.g. kgf
48       * @return double; the conversion factor from the provided units (e.g. m.kgf) to the standard unit (e.g., Nm or kg.m2/s2)
49       */
50      private static double factorLF(final LengthUnit length, final ForceUnit force)
51      {
52          return length.getScale().toStandardUnit(1.0) * force.getScale().toStandardUnit(1.0);
53      }
54  
55  }