1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.forces.gravity;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.hipparchus.util.FastMath;
23 import org.orekit.bodies.CelestialBodies;
24 import org.orekit.bodies.CelestialBody;
25 import org.orekit.propagation.FieldSpacecraftState;
26 import org.orekit.propagation.SpacecraftState;
27
28
29
30
31
32
33 public class ThirdBodyAttraction extends AbstractBodyAttraction {
34
35
36
37
38
39
40 public ThirdBodyAttraction(final CelestialBody body) {
41 super(body);
42 }
43
44
45 @Override
46 public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
47
48 final double gm = parameters[0];
49
50
51 final Vector3D centralToBody = getBody().getPosition(s.getDate(), s.getFrame());
52 final double r2Central = centralToBody.getNormSq();
53 final Vector3D satToBody = centralToBody.subtract(s.getPosition());
54 final double r2Sat = satToBody.getNormSq();
55
56
57 return new Vector3D(gm / (r2Sat * FastMath.sqrt(r2Sat)), satToBody,
58 -gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody);
59
60 }
61
62
63 @Override
64 public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
65 final T[] parameters) {
66
67 final T gm = parameters[0];
68
69
70 final FieldVector3D<T> centralToBody = getBody().getPosition(s.getDate(), s.getFrame());
71 final T r2Central = centralToBody.getNormSq();
72 final FieldVector3D<T> satToBody = centralToBody.subtract(s.getPosition());
73 final T r2Sat = satToBody.getNormSq();
74
75
76 return new FieldVector3D<>(r2Sat.multiply(r2Sat.sqrt()).reciprocal().multiply(gm), satToBody,
77 r2Central.multiply(r2Central.sqrt()).reciprocal().multiply(gm).negate(), centralToBody);
78
79 }
80
81 }