View Javadoc
1   package org.djunits.demo.website;
2   
3   import org.djunits.unit.LengthUnit;
4   import org.djunits.unit.LinearUnit;
5   import org.djunits.unit.DurationUnit;
6   import org.djunits.unit.unitsystem.UnitSystem;
7   
8   /**
9    * Example from the website to test if the code on the website is correct
10   * <p>
11   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
13   * </p>
14   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
15   * initial version Oct 16, 2016 <br>
16   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
19   */
20  @SuppressWarnings({ "javadoc" })
21  public class JerkUnit extends LinearUnit<JerkUnit>
22  {
23      private final LengthUnit lengthUnit;
24  
25      private final DurationUnit durationUnit;
26  
27      public static final JerkUnit SI;
28  
29      public static final JerkUnit M_PER_S3;
30  
31      public static final JerkUnit CM_PER_S3;
32  
33      public static final JerkUnit FT_PER_S3;
34  
35      public static final JerkUnit JERK;
36  
37      static
38      {
39          SI = new JerkUnit(LengthUnit.METER, DurationUnit.SECOND, "meter per cubed second", "m/s^3", UnitSystem.SI_BASE);
40          M_PER_S3 = SI;
41          CM_PER_S3 = new JerkUnit(LengthUnit.CENTIMETER, DurationUnit.SECOND, "centimeter per cubed second", "cm/s^3",
42                  UnitSystem.SI_BASE);
43          FT_PER_S3 = new JerkUnit(LengthUnit.FOOT, DurationUnit.SECOND, "foot per cubed second", "ft/s^3", UnitSystem.IMPERIAL);
44          JERK = new JerkUnit("jerk", "jerk", UnitSystem.OTHER, SI, 0.3048);
45      }
46  
47      public JerkUnit(final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name, final String abbreviation,
48              final UnitSystem unitSystem)
49      {
50          super(name, abbreviation, unitSystem, SI, lengthUnit.getScaleFactor() / Math.pow(durationUnit.getScaleFactor(), 3.0),
51                  false);
52          this.lengthUnit = lengthUnit;
53          this.durationUnit = durationUnit;
54      }
55  
56      public JerkUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final JerkUnit referenceUnit,
57              final double conversionFactorToReferenceUnit)
58      {
59          super(name, abbreviation, unitSystem, referenceUnit, conversionFactorToReferenceUnit, false);
60          this.lengthUnit = referenceUnit.getLengthUnit();
61          this.durationUnit = referenceUnit.getDurationUnit();
62      }
63  
64      public final LengthUnit getLengthUnit()
65      {
66          return this.lengthUnit;
67      }
68  
69      public final DurationUnit getDurationUnit()
70      {
71          return this.durationUnit;
72      }
73  
74      @Override
75      public final JerkUnit getStandardUnit()
76      {
77          return SI;
78      }
79  
80      @Override
81      public final String getSICoefficientsString()
82      {
83          return "m/s3";
84      }
85  }