1 package org.djunits.unit;
2
3 import org.djunits.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
10
11
12
13
14
15
16 public class AccelerationUnit extends Unit<AccelerationUnit>
17 {
18
19 private static final long serialVersionUID = 20140607L;
20
21
22 public static final Quantity<AccelerationUnit> BASE = new Quantity<>("Acceleration", "m/s2");
23
24
25 public static final AccelerationUnit SI = new AccelerationUnit().build(new Unit.Builder<AccelerationUnit>()
26 .setQuantity(BASE).setId("m/s2").setName("meter per second squared").setUnitSystem(UnitSystem.SI_DERIVED)
27 .setSiPrefixes(SIPrefixes.NONE, 1.0).setScale(IdentityScale.SCALE).setAdditionalAbbreviations("m/sec^2"));
28
29
30 public static final AccelerationUnit METER_PER_SECOND_2 = SI;
31
32
33 public static final AccelerationUnit KM_PER_HOUR_2 = SI.deriveLinear(factorLD("km", "h"), "km/h2",
34 "kilometer per hour squared", UnitSystem.SI_ACCEPTED, "km/h2", "km/h2", "km/hr^2", "km/hour^2");
35
36
37 public static final AccelerationUnit FOOT_PER_SECOND_2 = SI.deriveLinear(factorLD("ft", "s"), "ft/s2",
38 "foot per second squared", UnitSystem.IMPERIAL, "ft/s2", "ft/s2", "ft/sec^2");
39
40
41 public static final AccelerationUnit INCH_PER_SECOND_2 = SI.deriveLinear(factorLD("in", "s"), "in/s2",
42 "inch per second squared", UnitSystem.IMPERIAL, "in/s2", "in/s2", "in/sec^2");
43
44
45 public static final AccelerationUnit MILE_PER_HOUR_2 = SI.deriveLinear(factorLD("mi", "h"), "mi/h2",
46 "mile per hour squared", UnitSystem.IMPERIAL, "mi/h2", "mi/h2", "mi/hr^2", "mi/hour^2");
47
48
49 public static final AccelerationUnit MILE_PER_SECOND_2 = SI.deriveLinear(factorLD("mi", "s"), "mi/s2",
50 "mile per second squared", UnitSystem.IMPERIAL, "mi/s2", "mi/s2", "mi/sec^2");
51
52
53 public static final AccelerationUnit KNOT_PER_SECOND =
54 SI.deriveLinear(factorSD("kt", "s"), "kt/s", "knot per second", UnitSystem.OTHER, "kt/s", "kt/s", "kt/sec");
55
56
57 public static final AccelerationUnit MILE_PER_HOUR_PER_SECOND =
58 SI.deriveLinear(factorSD("mi/h", "s"), "mi/h/s", "mile per hour per second", UnitSystem.IMPERIAL, "mi/h/s",
59 "mi/h/s", "mi/hr/s", "mi/hour/s", "mi/h/sec", "mi/hr/sec", "mi/hour/sec");
60
61
62 public static final AccelerationUnit STANDARD_GRAVITY = SI.deriveLinear(9.80665, "g", "standard gravity", UnitSystem.OTHER);
63
64
65 public static final AccelerationUnit GAL = SI.deriveLinear(factorLD("cm", "s"), "Gal", "gal", UnitSystem.CGS);
66
67
68
69
70
71
72
73 private static double factorLD(final String length, final String duration)
74 {
75 double l = LengthUnit.BASE.of(length).getScale().toStandardUnit(1.0);
76 double d = DurationUnit.BASE.of(duration).getScale().toStandardUnit(1.0);
77 return l / (d * d);
78 }
79
80
81
82
83
84
85
86 private static double factorSD(final String speed, final String duration)
87 {
88 return SpeedUnit.BASE.of(speed).getScale().toStandardUnit(1.0)
89 / DurationUnit.BASE.of(duration).getScale().toStandardUnit(1.0);
90 }
91
92 }