1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19 import org.hamcrest.MatcherAssert;
20 import org.hamcrest.core.IsInstanceOf;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.junit.jupiter.api.Assertions;
23 import org.junit.jupiter.api.BeforeAll;
24 import org.junit.jupiter.api.Test;
25 import org.orekit.Utils;
26 import org.orekit.bodies.CelestialBody;
27 import org.orekit.bodies.CelestialBodyFactory;
28 import org.orekit.time.AbsoluteDate;
29 import org.orekit.time.TimeScale;
30 import org.orekit.time.TimeScalesFactory;
31 import org.orekit.utils.Constants;
32 import org.orekit.utils.IERSConventions;
33
34
35
36 public class EclipticProviderTest {
37
38
39 @BeforeAll
40 public static void setUpBefore() {
41 Utils.setDataRoot("regular-data");
42 }
43
44
45
46
47
48
49
50 @Test
51 public void testAgreementWith406Ephemerides() throws Exception {
52 TimeScale utc = TimeScalesFactory.getUTC();
53
54
55 checkAlignment(new AbsoluteDate(1969, 5, 27, utc), new AbsoluteDate(1969, 9, 20, utc));
56 checkAlignment(new AbsoluteDate(1969, 12, 5, utc), new AbsoluteDate(1970, 4, 1, utc));
57 checkAlignment(new AbsoluteDate(1970, 6, 15, utc), new AbsoluteDate(1970, 8, 1, utc));
58 checkAlignment(new AbsoluteDate(2002, 12, 16, utc), new AbsoluteDate(2004, 2, 3, utc));
59
60 checkAlignment(new AbsoluteDate(1999, 11, 22, utc), new AbsoluteDate(2000, 5, 21, utc));
61 }
62
63
64
65
66
67
68
69
70 private void checkAlignment(AbsoluteDate start, AbsoluteDate end) {
71
72 CelestialBody sun = CelestialBodyFactory.getSun();
73 CelestialBody emb = CelestialBodyFactory.getEarthMoonBarycenter();
74 Frame heliocentric = sun.getInertiallyOrientedFrame();
75
76 Frame ecliptic = FramesFactory.getEcliptic(IERSConventions.IERS_2010);
77
78
79
80
81 double preciseTol = 0.50 * Constants.ARC_SECONDS_TO_RADIANS;
82 for (AbsoluteDate date = start;
83 date.compareTo(end) < 0;
84 date = date.shiftedBy(Constants.JULIAN_YEAR / 12.0)) {
85
86 Transform heliocentricToEcliptic = heliocentric.getTransformTo(ecliptic, date);
87 Vector3D momentum = emb.getPVCoordinates(date, heliocentric).getMomentum();
88 Vector3D actual = heliocentricToEcliptic.transformVector(momentum);
89 double angle = Vector3D.angle(
90 Vector3D.PLUS_K,
91 actual
92 );
93 Assertions.assertEquals(0, angle, preciseTol,"Agrees with ephemerides to within " + preciseTol);
94
95 }
96
97 }
98
99
100
101
102 @Test
103 public void testGetName() {
104 Assertions.assertEquals("Ecliptic/1996",
105 FramesFactory.getEcliptic(IERSConventions.IERS_1996).getName());
106 Assertions.assertEquals("Ecliptic/2003",
107 FramesFactory.getEcliptic(IERSConventions.IERS_2003).getName());
108 Assertions.assertEquals("Ecliptic/2010",
109 FramesFactory.getEcliptic(IERSConventions.IERS_2010).getName());
110 }
111
112
113
114
115 @Test
116 public void testGetParent() {
117
118 Frame frame = FramesFactory.getEcliptic(IERSConventions.IERS_2003);
119
120
121 MatcherAssert.assertThat(frame.getParent().getTransformProvider(),
122 IsInstanceOf.instanceOf(MODProvider.class));
123 }
124
125 }