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