1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.models.earth.tessellation;
18
19 import org.hipparchus.util.FastMath;
20 import org.junit.jupiter.api.Assertions;
21 import org.junit.jupiter.api.Test;
22 import org.orekit.bodies.GeodeticPoint;
23
24 import static org.hamcrest.MatcherAssert.assertThat;
25 import static org.orekit.OrekitMatchers.geodeticPointCloseTo;
26
27 public class TileTest {
28
29 @Test
30 public void testCenteredSquare() {
31 double angle = 0.25;
32 GeodeticPoint v0 = new GeodeticPoint(-angle, -angle, 100.0);
33 GeodeticPoint v1 = new GeodeticPoint(-angle, +angle, 100.0);
34 GeodeticPoint v2 = new GeodeticPoint(+angle, -angle, 100.0);
35 GeodeticPoint v3 = new GeodeticPoint(+angle, +angle, 100.0);
36 Tile tile = new Tile(v0, v1, v2, v3);
37 assertThat(tile.getVertices()[0], geodeticPointCloseTo(v0, 1.0e-9));
38 assertThat(tile.getVertices()[1], geodeticPointCloseTo(v1, 1.0e-9));
39 assertThat(tile.getVertices()[2], geodeticPointCloseTo(v2, 1.0e-9));
40 assertThat(tile.getVertices()[3], geodeticPointCloseTo(v3, 1.0e-9));
41 assertThat(tile.getVertices()[3], geodeticPointCloseTo(v3, 1.0e-9));
42
43 assertThat(tile.getInterpolatedPoint(0, 0), geodeticPointCloseTo(v0, 1.0e-9));
44 assertThat(tile.getInterpolatedPoint(1, 0), geodeticPointCloseTo(v1, 1.0e-9));
45 assertThat(tile.getInterpolatedPoint(1, 1), geodeticPointCloseTo(v2, 1.0e-9));
46 assertThat(tile.getInterpolatedPoint(0, 1), geodeticPointCloseTo(v3, 1.0e-9));
47
48 assertThat(tile.getCenter(),
49 geodeticPointCloseTo(new GeodeticPoint(0.0, 0.0, 100.0), 1.0e-9));
50
51 }
52
53 @Test
54 public void testPoleCentered() {
55 double latitude = 0.25;
56 GeodeticPoint v0 = new GeodeticPoint(latitude, 0.0 * FastMath.PI, 100.0);
57 GeodeticPoint v1 = new GeodeticPoint(latitude, 0.5 * FastMath.PI, 200.0);
58 GeodeticPoint v2 = new GeodeticPoint(latitude, 1.0 * FastMath.PI, 300.0);
59 GeodeticPoint v3 = new GeodeticPoint(latitude, 1.5 * FastMath.PI, 200.0);
60 Tile tile = new Tile(v0, v1, v2, v3);
61 assertThat(tile.getVertices()[0], geodeticPointCloseTo(v0, 1.0e-9));
62 assertThat(tile.getVertices()[1], geodeticPointCloseTo(v1, 1.0e-9));
63 assertThat(tile.getVertices()[2], geodeticPointCloseTo(v2, 1.0e-9));
64 assertThat(tile.getVertices()[3], geodeticPointCloseTo(v3, 1.0e-9));
65 assertThat(tile.getVertices()[3], geodeticPointCloseTo(v3, 1.0e-9));
66
67 assertThat(tile.getInterpolatedPoint(0, 0), geodeticPointCloseTo(v0, 1.0e-9));
68 assertThat(tile.getInterpolatedPoint(1, 0), geodeticPointCloseTo(v1, 1.0e-9));
69 assertThat(tile.getInterpolatedPoint(1, 1), geodeticPointCloseTo(v2, 1.0e-9));
70 assertThat(tile.getInterpolatedPoint(0, 1), geodeticPointCloseTo(v3, 1.0e-9));
71
72 Assertions.assertEquals(0.5 * FastMath.PI, tile.getCenter().getLatitude(), 1.0e-9);
73
74 }
75
76 }