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.SpeedUnit;
6   import org.djunits.value.ValueRuntimeException;
7   import org.djunits.value.storage.StorageType;
8   import org.djunits.value.vdouble.scalar.Duration;
9   import org.djunits.value.vdouble.scalar.Length;
10  import org.djunits.value.vdouble.scalar.Speed;
11  import org.djunits.value.vdouble.vector.base.DoubleVector;
12  
13  /**
14   * <p>
15   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
17   * </p>
18   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
20   * @author <a href="https://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21   */
22  public final class Test
23  {
24      /** Furlong example. */
25      public static final LengthUnit FURLONG = LengthUnit.FOOT.deriveLinear(660.0, "fr", "Furlong");
26  
27      /** Fortnight example. */
28      public static final DurationUnit FORTNIGHT = DurationUnit.DAY.deriveLinear(14.0, "fn", "Fortnight");
29  
30      /** fr/fn example. */
31      public static final SpeedUnit FURLONGS_PER_FORTNIGHT =
32              SpeedUnit.SI.deriveLinear(FURLONG.getScale().toStandardUnit(1.0) / FORTNIGHT.getScale().toStandardUnit(1.0),
33                      "fr/fn", "Furlongs per Fortnight");
34  
35      /** */
36      private Test()
37      {
38          // utility class
39      }
40  
41      /**
42       * @param args String[]; args
43       * @throws ValueRuntimeException on error
44       */
45      public static void main(final String[] args) throws ValueRuntimeException
46      {
47          Length fr1000 = new Length(1000.0, FURLONG);
48          Duration twoWeeks = new Duration(1.0, FORTNIGHT);
49          Speed speed = fr1000.divide(twoWeeks);
50          System.out.println(speed);
51          System.out.println(speed.toString(FURLONGS_PER_FORTNIGHT));
52          System.out.println();
53  
54          JerkJerk.html#Jerk">Jerk jerk1 = new Jerk(1.2, JerkUnit.SI);
55          System.out.println("jerk1 = Jerk(1.2, JerkUnit.SI) : " + jerk1);
56          Jerk jerk2 = jerk1.times(2.0);
57          System.out.println("jerk2 = jerk1.multiplyBy(2.0)                    : " + jerk2);
58          double[] sv = new double[] {1, 2, 3, 4, 5};
59          JerkVector jerkVector = DoubleVector.instantiate(sv, JerkUnit.SI, StorageType.DENSE);
60          System.out.println("jerkVector: : " + jerkVector);
61  
62          Jerkerk.html#Jerk">Jerk jjerk1 = new Jerk(1.2, JerkUnit.SI);
63          System.out.println("jerk1 = new Jerk(1.2, JerkUnit.SI) : " + jjerk1);
64          Jerk jjerk2 = jjerk1.times(2.0);
65          System.out.println("jerk2 = jerk1.multiplyBy(2.0)      : " + jjerk2);
66  
67          double[][] data = new double[1000][1000];
68          for (int i = 0; i < 1000; i++)
69          {
70              for (int j = 0; j < 1000; j++)
71              {
72                  data[i][j] = 9 * i + 2 * j * 0.364;
73              }
74          }
75      }
76  
77  }