1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.geometry.euclidean.threed.rotation;
18
19 import org.apache.commons.geometry.euclidean.threed.Vector3D;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.Test;
22
23 class AxisSequenceTest {
24
25 @Test
26 void testAxes() {
27
28 for (final AxisSequence axes : AxisSequence.values()) {
29 checkAxes(axes);
30 }
31 }
32
33 private void checkAxes(final AxisSequence axes) {
34
35
36 final String name = axes.toString();
37
38 final Vector3D a1 = getAxisForName(name.substring(0, 1));
39 final Vector3D a2 = getAxisForName(name.substring(1, 2));
40 final Vector3D a3 = getAxisForName(name.substring(2, 3));
41
42
43 Assertions.assertEquals(a1, axes.getAxis1());
44 Assertions.assertEquals(a2, axes.getAxis2());
45 Assertions.assertEquals(a3, axes.getAxis3());
46
47 Assertions.assertArrayEquals(new Vector3D[] {a1, a2, a3}, axes.toArray());
48 }
49
50 private Vector3D getAxisForName(final String name) {
51 if ("X".equals(name)) {
52 return Vector3D.Unit.PLUS_X;
53 }
54 if ("Y".equals(name)) {
55 return Vector3D.Unit.PLUS_Y;
56 }
57 if ("Z".equals(name)) {
58 return Vector3D.Unit.PLUS_Z;
59 }
60 throw new IllegalArgumentException("Unknown axis: " + name);
61 }
62 }