1 package org.djutils.draw;
2
3 import org.djutils.draw.point.Point3d;
4
5 /**
6 * CombinedRotations.java.
7 * <p>
8 * Copyright (c) 2020-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
9 * BSD-style license. See <a href="https://djutils.org/docs/current/djutils/licenses.html">DJUTILS License</a>.
10 * </p>
11 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
12 * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a>
13 */
14 public final class CombinedRotations
15 {
16 /**
17 * Do not instantiate.
18 */
19 private CombinedRotations()
20 {
21 // Cannot be instantiated
22 }
23
24 /**
25 * Demonstrate all combinations of 90 degree rotations.
26 * @param args String[]; the command line arguments (not used)
27 */
28 public static void main(final String[] args)
29 {
30 Point3d unitVector = new Point3d(1, 0, 0);
31 double[] rotations = new double[] {0, Math.PI / 2, Math.PI, -Math.PI / 2};
32 for (double rotX : rotations)
33 {
34 for (double rotY : rotations)
35 {
36 for (double rotZ : rotations)
37 {
38 Transform3d combinedTransform = new Transform3d().rotZ(rotZ).rotY(rotY).rotX(rotX);
39 System.out.println(String.format(
40 "rotX=%4.0f, rotY=%4.0f, rotZ=%4.0f, transformed unit vector %s, transformation Matrix %s",
41 Math.toDegrees(rotX), Math.toDegrees(rotY), Math.toDegrees(rotZ),
42 combinedTransform.transform(unitVector).toString("%4.0f"), combinedTransform));
43 }
44 }
45 }
46 }
47 }