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.geometry.euclidean.threed.Vector3D;
20 import org.hipparchus.util.FastMath;
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23
24
25
26
27
28
29
30 public class GeodeticPointTest {
31
32
33
34
35
36 @Test
37 void testGeodeticPointAngleNormalization() {
38
39 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(135),
40 FastMath.toRadians(90 - 360), 0);
41
42
43 Assertions.assertEquals(FastMath.toRadians(45), point.getLatitude(), 0);
44 Assertions.assertEquals(FastMath.toRadians(-90), point.getLongitude(), 0);
45
46 Assertions.assertEquals(0, Vector3D.distance(point.getEast(), Vector3D.PLUS_I), 1.0e-15);
47 Assertions.assertEquals(0, Vector3D.distance(point.getNorth(), new Vector3D( 0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
48 Assertions.assertEquals(0, Vector3D.distance(point.getWest(), Vector3D.MINUS_I), 1.0e-15);
49 Assertions.assertEquals(0, Vector3D.distance(point.getSouth(), new Vector3D(-0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
50 Assertions.assertEquals(0, Vector3D.distance(point.getZenith(), new Vector3D(-0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
51 Assertions.assertEquals(0, Vector3D.distance(point.getNadir(), new Vector3D( 0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
52
53 }
54
55
56
57
58
59 @Test
60 void testGeodeticPoint() {
61
62
63 final double pi = FastMath.PI;
64 double[][] points = {
65
66
67 { pi / 6, pi / 6, pi / 6, pi / 6 },
68
69 { 4 * pi / 6, 4 * pi / 6, pi / 3, -pi / 3 },
70
71 { 7 * pi / 6, 7 * pi / 6, -pi / 6, pi / 6 },
72
73 { -pi / 6, -pi / 6, -pi / 6, -pi / 6 },
74 { -4 * pi / 6, -4 * pi / 6, -pi / 3, pi / 3 },
75 { -pi / 6, -4 * pi / 3, -pi / 6, 2 * pi / 3 } };
76
77 for (double[] point : points) {
78
79 GeodeticPoint gp = new GeodeticPoint(point[0], point[1], 0);
80 Assertions.assertEquals(0, gp.getEast().crossProduct(gp.getNorth()).distance(gp.getZenith()), 1.0e-15);
81 Assertions.assertEquals(0, gp.getNorth().crossProduct(gp.getWest()).distance(gp.getZenith()), 1.0e-15);
82 Assertions.assertEquals(0, gp.getSouth().crossProduct(gp.getWest()).distance(gp.getNadir()), 1.0e-15);
83 Assertions.assertEquals(0, gp.getEast().crossProduct(gp.getSouth()).distance(gp.getNadir()), 1.0e-15);
84 Assertions.assertEquals(0, gp.getZenith().crossProduct(gp.getSouth()).distance(gp.getEast()), 1.0e-15);
85 Assertions.assertEquals(0, gp.getNadir().crossProduct(gp.getWest()).distance(gp.getNorth()), 1.0e-15);
86
87
88 Assertions.assertEquals(point[2], gp.getLatitude(), 5 * FastMath.ulp(point[2]));
89 Assertions.assertEquals(point[3], gp.getLongitude(), 5 * FastMath.ulp(point[3]));
90 }
91 }
92
93
94
95
96 @Test
97 void testEquals() {
98
99 GeodeticPoint point = new GeodeticPoint(1, 2, 3);
100
101
102 Assertions.assertEquals(point, new GeodeticPoint(1, 2, 3));
103 Assertions.assertFalse(point.equals(new GeodeticPoint(0, 2, 3)));
104 Assertions.assertFalse(point.equals(new GeodeticPoint(1, 0, 3)));
105 Assertions.assertFalse(point.equals(new GeodeticPoint(1, 2, 0)));
106 Assertions.assertFalse(point.equals(new Object()));
107 Assertions.assertEquals(point.hashCode(), new GeodeticPoint(1, 2, 3).hashCode());
108 Assertions.assertNotEquals(point.hashCode(), new GeodeticPoint(1, FastMath.nextUp(2), 3).hashCode());
109 }
110
111
112
113
114 @Test
115 void testToString() {
116
117 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(30),
118 FastMath.toRadians(60), 90);
119
120
121 String actual = point.toString();
122
123
124 Assertions.assertEquals("{lat: 30 deg, lon: 60 deg, alt: 90}", actual);
125 }
126 }