View Javadoc
1   package org.djunits.demo.website;
2   
3   import org.djunits.unit.DurationUnit;
4   import org.djunits.unit.LengthUnit;
5   import org.djunits.unit.LinearUnit;
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          this.lengthUnit = lengthUnit;
52          this.durationUnit = durationUnit;
53      }
54  
55      public JerkUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final JerkUnit referenceUnit,
56              final double conversionFactorToReferenceUnit)
57      {
58          super(name, abbreviation, unitSystem, referenceUnit, conversionFactorToReferenceUnit);
59          this.lengthUnit = referenceUnit.getLengthUnit();
60          this.durationUnit = referenceUnit.getDurationUnit();
61      }
62  
63      public final LengthUnit getLengthUnit()
64      {
65          return this.lengthUnit;
66      }
67  
68      public final DurationUnit getDurationUnit()
69      {
70          return this.durationUnit;
71      }
72  
73      @Override
74      public final JerkUnit getStandardUnit()
75      {
76          return SI;
77      }
78  
79      @Override
80      public final String getSICoefficientsString()
81      {
82          return "m/s3";
83      }
84  }