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 java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.hipparchus.util.FastMath;
26 import org.orekit.forces.ForceModel;
27 import org.orekit.frames.FieldStaticTransform;
28 import org.orekit.frames.Frame;
29 import org.orekit.frames.StaticTransform;
30 import org.orekit.propagation.FieldSpacecraftState;
31 import org.orekit.propagation.SpacecraftState;
32 import org.orekit.utils.Constants;
33 import org.orekit.utils.FieldPVCoordinates;
34 import org.orekit.utils.PVCoordinates;
35 import org.orekit.utils.ParameterDriver;
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public class LenseThirringRelativity implements ForceModel {
50
51
52 private static final double J = 9.8e8;
53
54
55
56
57
58
59
60 private static final double MU_SCALE = FastMath.scalb(1.0, 32);
61
62
63 private final ParameterDriver gmParameterDriver;
64
65
66 private final Frame bodyFrame;
67
68
69
70
71
72
73 public LenseThirringRelativity(final double gm, final Frame bodyFrame) {
74 gmParameterDriver = new ParameterDriver(NewtonianAttraction.CENTRAL_ATTRACTION_COEFFICIENT,
75 gm, MU_SCALE,
76 0.0, Double.POSITIVE_INFINITY);
77 this.bodyFrame = bodyFrame;
78 }
79
80
81 @Override
82 public boolean dependsOnPositionOnly() {
83 return false;
84 }
85
86
87 @Override
88 public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
89
90
91 final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;
92
93
94 final double gm = parameters[0];
95
96
97 final PVCoordinates pv = s.getPVCoordinates();
98 final Vector3D p = pv.getPosition();
99 final Vector3D v = pv.getVelocity();
100
101
102 final double r = p.getNorm();
103 final double r2 = r * r;
104
105
106 final StaticTransform t =
107 bodyFrame.getStaticTransformTo(s.getFrame(), s.getDate());
108 final Vector3D j = t.transformVector(Vector3D.PLUS_K).scalarMultiply(J);
109
110
111 return new Vector3D(3.0 * p.dotProduct(j) / r2,
112 p.crossProduct(v),
113 1.0,
114 v.crossProduct(j))
115 .scalarMultiply((2.0 * gm) / (r2 * r * c2));
116 }
117
118
119 @Override
120 public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
121 final T[] parameters) {
122
123
124 final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;
125
126
127 final T gm = parameters[0];
128
129
130 final FieldPVCoordinates<T> pv = s.getPVCoordinates();
131 final FieldVector3D<T> p = pv.getPosition();
132 final FieldVector3D<T> v = pv.getVelocity();
133
134
135 final T r = p.getNorm();
136 final T r2 = r.square();
137
138
139 final FieldStaticTransform<T> t = bodyFrame.getStaticTransformTo(s.getFrame(), s.getDate());
140 final FieldVector3D<T> j = t.transformVector(Vector3D.PLUS_K).scalarMultiply(J);
141
142 return new FieldVector3D<>(p.dotProduct(j).multiply(3.0).divide(r2),
143 p.crossProduct(v),
144 r.getField().getOne(),
145 v.crossProduct(j))
146 .scalarMultiply(gm.multiply(2.0).divide(r2.multiply(r).multiply(c2)));
147 }
148
149
150 @Override
151 public List<ParameterDriver> getParametersDrivers() {
152 return Collections.singletonList(gmParameterDriver);
153 }
154
155 }