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