1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.hipparchus.geometry.euclidean.threed;
19
20 import org.hipparchus.CalculusFieldElement;
21 import org.hipparchus.Field;
22 import org.hipparchus.util.Binary64Field;
23 import org.junit.Assert;
24 import org.junit.Test;
25
26 public class RotationStageTest {
27
28 @Test
29 public void testAxis() {
30 Assert.assertEquals(0.0,
31 Vector3D.distance(Vector3D.PLUS_I, RotationStage.X.getAxis()),
32 1.0e-15);
33 Assert.assertEquals(0.0,
34 Vector3D.distance(Vector3D.PLUS_J, RotationStage.Y.getAxis()),
35 1.0e-15);
36 Assert.assertEquals(0.0,
37 Vector3D.distance(Vector3D.PLUS_K, RotationStage.Z.getAxis()),
38 1.0e-15);
39 }
40
41 @Test
42 public void testComponent() {
43 final Vector3D v = new Vector3D(1.0, 2.0, 3.0);
44 Assert.assertEquals( 1.0, RotationStage.X.getComponent(v), 1.0e-15);
45 Assert.assertEquals( 2.0, RotationStage.Y.getComponent(v), 1.0e-15);
46 Assert.assertEquals( 3.0, RotationStage.Z.getComponent(v), 1.0e-15);
47 }
48
49 @Test
50 public void testFieldComponent() {
51 doTestFieldComponent(Binary64Field.getInstance());
52 }
53
54 private <T extends CalculusFieldElement<T>> void doTestFieldComponent(final Field<T> field) {
55 final FieldVector3D<T> v = new FieldVector3D<>(field.getZero().newInstance(1.0),
56 field.getZero().newInstance(2.0),
57 field.getZero().newInstance(3.0));
58 Assert.assertEquals( 1.0, RotationStage.X.getComponent(v).getReal(), 1.0e-15);
59 Assert.assertEquals( 2.0, RotationStage.Y.getComponent(v).getReal(), 1.0e-15);
60 Assert.assertEquals( 3.0, RotationStage.Z.getComponent(v).getReal(), 1.0e-15);
61 }
62
63 }