1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.bodies;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.Vector3D;
21 import org.hipparchus.util.Decimal64;
22 import org.hipparchus.util.FastMath;
23 import org.junit.Assert;
24 import org.junit.Test;
25
26
27
28
29
30
31
32 public class FieldGeodeticPointTest {
33
34
35
36
37
38 @Test
39 public void testGeodeticPointAngleNormalization() {
40
41 FieldGeodeticPoint<Decimal64> point =
42 new FieldGeodeticPoint<Decimal64>(new Decimal64(FastMath.toRadians(135)),
43 new Decimal64(FastMath.toRadians(90 - 360)),
44 new Decimal64(0));
45
46
47 Assert.assertEquals(FastMath.toRadians(45), point.getLatitude().getReal(), 1.0e-15);
48 Assert.assertEquals(FastMath.toRadians(-90), point.getLongitude().getReal(), 1.0e-15);
49
50 Assert.assertEquals(0, Vector3D.distance(point.getEast().toVector3D(), Vector3D.PLUS_I), 1.0e-15);
51 Assert.assertEquals(0, Vector3D.distance(point.getNorth().toVector3D(), new Vector3D( 0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
52 Assert.assertEquals(0, Vector3D.distance(point.getWest().toVector3D(), Vector3D.MINUS_I), 1.0e-15);
53 Assert.assertEquals(0, Vector3D.distance(point.getSouth().toVector3D(), new Vector3D(-0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
54 Assert.assertEquals(0, Vector3D.distance(point.getZenith().toVector3D(), new Vector3D(-0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
55 Assert.assertEquals(0, Vector3D.distance(point.getNadir().toVector3D(), new Vector3D( 0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
56
57 }
58
59
60
61
62
63 @Test
64 public void testGeodeticPoint() {
65
66
67 final double pi = FastMath.PI;
68 double[][] points = {
69
70
71 { pi / 6, pi / 6, pi / 6, pi / 6 },
72
73 { 4 * pi / 6, 4 * pi / 6, pi / 3, -pi / 3 },
74
75 { 7 * pi / 6, 7 * pi / 6, -pi / 6, pi / 6 },
76
77 { -pi / 6, -pi / 6, -pi / 6, -pi / 6 },
78 { -4 * pi / 6, -4 * pi / 6, -pi / 3, pi / 3 },
79 { -pi / 6, -4 * pi / 3, -pi / 6, 2 * pi / 3 } };
80
81 for (double[] point : points) {
82
83 FieldGeodeticPoint<Decimal64> gp =
84 new FieldGeodeticPoint<Decimal64>(new Decimal64(point[0]),
85 new Decimal64(point[1]),
86 Decimal64.ZERO);
87 Assert.assertEquals(0, gp.getEast().crossProduct(gp.getNorth()).distance(gp.getZenith()).getReal(), 1.0e-15);
88 Assert.assertEquals(0, gp.getNorth().crossProduct(gp.getWest()).distance(gp.getZenith()).getReal(), 1.0e-15);
89 Assert.assertEquals(0, gp.getSouth().crossProduct(gp.getWest()).distance(gp.getNadir()).getReal(), 1.0e-15);
90 Assert.assertEquals(0, gp.getEast().crossProduct(gp.getSouth()).distance(gp.getNadir()).getReal(), 1.0e-15);
91 Assert.assertEquals(0, gp.getZenith().crossProduct(gp.getSouth()).distance(gp.getEast()).getReal(), 1.0e-15);
92 Assert.assertEquals(0, gp.getNadir().crossProduct(gp.getWest()).distance(gp.getNorth()).getReal(), 1.0e-15);
93
94
95 Assert.assertEquals(point[2], gp.getLatitude().getReal(), 5 * FastMath.ulp(point[2]));
96 Assert.assertEquals(point[3], gp.getLongitude().getReal(), 5 * FastMath.ulp(point[3]));
97 }
98 }
99
100
101
102
103 @Test
104 public void testEquals() {
105
106 FieldGeodeticPoint<Decimal64> point =
107 new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
108 new Decimal64(2),
109 new Decimal64(3));
110
111
112 Assert.assertEquals(point, new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
113 new Decimal64(2),
114 new Decimal64(3)));
115 Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(0),
116 new Decimal64(2),
117 new Decimal64(3))));
118 Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
119 new Decimal64(0),
120 new Decimal64(3))));
121 Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
122 new Decimal64(2),
123 new Decimal64(0))));
124 Assert.assertFalse(point.equals(new Object()));
125 Assert.assertEquals(point.hashCode(),
126 new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
127 new Decimal64(2),
128 new Decimal64(3)).hashCode());
129 Assert.assertNotEquals(point.hashCode(),
130 new FieldGeodeticPoint<Decimal64>(new Decimal64(1),
131 new Decimal64(FastMath.nextUp(2)),
132 new Decimal64(3)).hashCode());
133 }
134
135
136
137
138 @Test
139 public void testToString() {
140
141 FieldGeodeticPoint<Decimal64> point =
142 new FieldGeodeticPoint<Decimal64>(new Decimal64(FastMath.toRadians(30)),
143 new Decimal64(FastMath.toRadians(60)),
144 new Decimal64(90));
145
146
147 String actual = point.toString();
148
149
150 Assert.assertEquals("{lat: 30 deg, lon: 60 deg, alt: 90}", actual);
151 }
152
153 }