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.hipparchus.CalculusFieldElement;
20 import org.hipparchus.Field;
21 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
22 import org.hipparchus.geometry.euclidean.threed.Vector3D;
23 import org.hipparchus.util.Binary64Field;
24 import org.hipparchus.util.FastMath;
25 import org.junit.jupiter.api.Assertions;
26 import org.junit.jupiter.api.BeforeEach;
27 import org.junit.jupiter.api.Test;
28 import org.orekit.Utils;
29 import org.orekit.bodies.CelestialBody;
30 import org.orekit.bodies.CelestialBodyFactory;
31 import org.orekit.time.AbsoluteDate;
32 import org.orekit.time.FieldAbsoluteDate;
33 import org.orekit.time.TimeScalesFactory;
34 import org.orekit.utils.Constants;
35 import org.orekit.utils.FieldPVCoordinates;
36
37
38
39
40
41
42 public class L1TransformProviderTest {
43
44 @Test
45 public void testTransformationOrientationForEarthMoon() {
46
47
48 final CelestialBody earth = CelestialBodyFactory.getEarth();
49 final CelestialBody moon = CelestialBodyFactory.getMoon();
50
51
52 final Frame eme2000 = FramesFactory.getEME2000();
53 final Frame l1Frame = new L1Frame(earth, moon);
54
55
56 final AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 0, 0, 00.000,
57 TimeScalesFactory.getUTC());
58
59
60 Vector3D posMoon = moon.getPosition(date, eme2000);
61
62
63
64
65
66 Vector3D posL1 = l1Frame.getStaticTransformTo(eme2000,date).transformPosition(Vector3D.ZERO);
67
68
69 Assertions.assertEquals(0.0, Vector3D.angle(posMoon, posL1), 1.0e-10);
70
71
72 Assertions.assertTrue(posMoon.getNorm() > posL1.getNorm() + 4.0e7);
73
74 }
75
76 @Test
77 public void testFieldTransformationOrientationForEarthMoon() {
78 doTestFieldTransformationOrientationForEarthMoon(Binary64Field.getInstance());
79 }
80
81 private <T extends CalculusFieldElement<T>> void doTestFieldTransformationOrientationForEarthMoon(final Field<T> field) {
82
83
84 final CelestialBody earth = CelestialBodyFactory.getEarth();
85 final CelestialBody moon = CelestialBodyFactory.getMoon();
86
87
88 final Frame eme2000 = FramesFactory.getEME2000();
89 final Frame l1Frame = new L1Frame(earth, moon);
90
91
92 final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2000, 01, 01, 0, 0, 00.000,
93 TimeScalesFactory.getUTC());
94
95
96 FieldPVCoordinates<T> pvMoon = moon.getPVCoordinates(date, eme2000);
97 FieldVector3D<T> posMoon = pvMoon.getPosition();
98
99
100
101
102
103 FieldVector3D<T> posL1 = l1Frame.getTransformTo(eme2000,date).transformPosition(Vector3D.ZERO);
104
105
106 Assertions.assertEquals(0.0, FieldVector3D.angle(posMoon, posL1).getReal(), 1.0e-10);
107
108
109 Assertions.assertTrue(posMoon.getNorm().getReal() > posL1.getNorm().getReal() + 4.0e7);
110
111 }
112
113
114 @Test
115 public void testSunEarth() {
116
117
118 final CelestialBody sun = CelestialBodyFactory.getSun();
119 final CelestialBody earth = CelestialBodyFactory.getEarth();
120
121
122 final Frame sunFrame = sun.getInertiallyOrientedFrame();
123 final Frame l1Frame = new L1Frame(sun, earth);
124
125
126 final AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 0, 0, 00.000,
127 TimeScalesFactory.getUTC());
128
129
130 Vector3D posEarth = earth.getPosition(date, sunFrame);
131
132
133
134
135
136 Vector3D posL1 = l1Frame.getStaticTransformTo(sunFrame,date).transformPosition(Vector3D.ZERO);
137
138
139 Assertions.assertEquals(0.0, Vector3D.angle(posEarth, posL1), 1.0e-10);
140
141
142 Assertions.assertTrue(posEarth.getNorm() > posL1.getNorm() + 1.0e9);
143 }
144
145 @Test
146 public void testFieldSunEarth() {
147 doTestFieldSunEarth(Binary64Field.getInstance());
148 }
149
150 private <T extends CalculusFieldElement<T>> void doTestFieldSunEarth(final Field<T> field) {
151
152
153 final CelestialBody sun = CelestialBodyFactory.getSun();
154 final CelestialBody earth = CelestialBodyFactory.getEarth();
155
156
157 final Frame sunFrame = sun.getInertiallyOrientedFrame();
158 final Frame l1Frame = new L1Frame(sun, earth);
159
160
161 final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2000, 01, 01, 0, 0, 00.000,
162 TimeScalesFactory.getUTC());
163
164
165 FieldPVCoordinates<T> pvEarth = earth.getPVCoordinates(date, sunFrame);
166 FieldVector3D<T> posEarth = pvEarth.getPosition();
167
168
169
170
171
172 FieldVector3D<T> posL1 = l1Frame.getStaticTransformTo(sunFrame,date).transformPosition(Vector3D.ZERO);
173
174
175 Assertions.assertEquals(0.0, FieldVector3D.angle(posEarth, posL1).getReal(), 1.0e-10);
176
177
178 Assertions.assertTrue(posEarth.getNorm().getReal() > posL1.getNorm().getReal() + 1.0e9);
179 }
180
181 @Test
182 public void testSunJupiter() {
183
184
185 final CelestialBody sun = CelestialBodyFactory.getSun();
186 final CelestialBody jupiter = CelestialBodyFactory.getJupiter();
187
188
189 final Frame sunFrame = sun.getInertiallyOrientedFrame();
190 final Frame l1Frame = new L1Frame(sun, jupiter);
191
192
193 final AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 0, 0, 00.000,
194 TimeScalesFactory.getUTC());
195
196
197 Vector3D posJupiter = jupiter.getPosition(date, sunFrame);
198
199
200
201
202
203 Vector3D posL1 = l1Frame.getStaticTransformTo(sunFrame,date).transformPosition(Vector3D.ZERO);
204
205
206 Assertions.assertEquals(0.0, Vector3D.angle(posJupiter, posL1), 1.0e-10);
207
208
209 Assertions.assertTrue(posJupiter.getNorm() > posL1.getNorm() + 4.5e10);
210 }
211
212 @Test
213 public void testFieldSunJupiter() {
214 doTestFieldSunJupiter(Binary64Field.getInstance());
215 }
216
217 private <T extends CalculusFieldElement<T>> void doTestFieldSunJupiter(final Field<T> field) {
218
219
220 final CelestialBody sun = CelestialBodyFactory.getSun();
221 final CelestialBody jupiter = CelestialBodyFactory.getJupiter();
222
223
224 final Frame sunFrame = sun.getInertiallyOrientedFrame();
225 final Frame l1Frame = new L1Frame(sun, jupiter);
226
227
228 final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2000, 01, 01, 0, 0, 00.000,
229 TimeScalesFactory.getUTC());
230
231
232 FieldPVCoordinates<T> pvJupiter = jupiter.getPVCoordinates(date, sunFrame);
233 FieldVector3D<T> posJupiter = pvJupiter.getPosition();
234
235
236
237
238
239 FieldVector3D<T> posL1 = l1Frame.getStaticTransformTo(sunFrame,date).transformPosition(Vector3D.ZERO);
240
241
242 Assertions.assertEquals(0.0, FieldVector3D.angle(posJupiter, posL1).getReal(), 1.0e-10);
243
244
245 Assertions.assertTrue(posJupiter.getNorm().getReal() > posL1.getNorm().getReal() + 4.5e10);
246 }
247
248 @Test
249 public void testL1Orientation() {
250
251 final AbsoluteDate date0 = new AbsoluteDate(2000, 01, 1, 11, 58, 20.000,
252 TimeScalesFactory.getUTC());
253 final CelestialBody sun = CelestialBodyFactory.getSun();
254 final CelestialBody earth = CelestialBodyFactory.getEarth();
255 final Frame l1Frame = new L1Frame(sun, earth);
256 for (double dt = -Constants.JULIAN_DAY; dt <= Constants.JULIAN_DAY; dt += 3600.0) {
257 final AbsoluteDate date = date0.shiftedBy(dt);
258 final Vector3D sunPositionInL1 = sun.getPosition(date, l1Frame);
259 final Vector3D earthPositionInL1 = earth.getPosition(date, l1Frame);
260 Assertions.assertEquals(0.0, Vector3D.angle(sunPositionInL1, Vector3D.MINUS_I), 3.0e-14);
261 Assertions.assertEquals(FastMath.PI, Vector3D.angle(earthPositionInL1, Vector3D.MINUS_I), 3.0e-14);
262 }
263 }
264
265 @Test
266 public void testFieldL1Orientation() {
267 doTestFieldL1Orientation(Binary64Field.getInstance());
268 }
269
270 private <T extends CalculusFieldElement<T>> void doTestFieldL1Orientation(final Field<T> field) {
271
272 final FieldAbsoluteDate<T> date0 = new FieldAbsoluteDate<>(field, 2000, 01, 1, 11, 58, 20.000,
273 TimeScalesFactory.getUTC());
274 final CelestialBody sun = CelestialBodyFactory.getSun();
275 final CelestialBody earth = CelestialBodyFactory.getEarth();
276 final Frame l1Frame = new L1Frame(sun, earth);
277 for (double dt = -Constants.JULIAN_DAY; dt <= Constants.JULIAN_DAY; dt += 3600.0) {
278 final FieldAbsoluteDate<T> date = date0.shiftedBy(dt);
279 final FieldVector3D<T> sunPositionInL1 = sun.getPosition(date, l1Frame);
280 final FieldVector3D<T> earthPositionInL1 = earth.getPosition(date, l1Frame);
281 Assertions.assertEquals(0.0, FieldVector3D.angle(sunPositionInL1, Vector3D.MINUS_I).getReal(), 3.0e-14);
282 Assertions.assertEquals(FastMath.PI, FieldVector3D.angle(earthPositionInL1, Vector3D.MINUS_I).getReal(), 3.0e-14);
283 }
284 }
285
286 @BeforeEach
287 public void setUp() {
288 Utils.setDataRoot("regular-data");
289 }
290
291 }