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.apache.commons.math3.analysis.differentiation.DerivativeStructure;
20 import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation;
21 import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
22 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
23 import org.apache.commons.math3.ode.AbstractParameterizable;
24 import org.apache.commons.math3.util.FastMath;
25 import org.orekit.errors.OrekitException;
26 import org.orekit.forces.ForceModel;
27 import org.orekit.frames.Frame;
28 import org.orekit.propagation.SpacecraftState;
29 import org.orekit.propagation.events.EventDetector;
30 import org.orekit.propagation.numerical.TimeDerivativesEquations;
31 import org.orekit.time.AbsoluteDate;
32
33
34
35
36 public class NewtonianAttraction extends AbstractParameterizable implements ForceModel {
37
38
39 public static final String CENTRAL_ATTRACTION_COEFFICIENT = "central attraction coefficient";
40
41
42 private double mu;
43
44
45
46
47 public NewtonianAttraction(final double mu) {
48 super(CENTRAL_ATTRACTION_COEFFICIENT);
49 this.mu = mu;
50 }
51
52
53 public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame,
54 final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity,
55 final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass)
56 throws OrekitException {
57
58 final DerivativeStructure r2 = position.getNormSq();
59 return new FieldVector3D<DerivativeStructure>(r2.sqrt().multiply(r2).reciprocal().multiply(-mu), position);
60
61 }
62
63
64 public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s, final String paramName)
65 throws OrekitException {
66
67 complainIfNotSupported(paramName);
68
69 final Vector3D position = s.getPVCoordinates().getPosition();
70 final double r2 = position.getNormSq();
71 final DerivativeStructure muds = new DerivativeStructure(1, 1, 0, mu);
72 return new FieldVector3D<DerivativeStructure>(muds.divide(-r2 * FastMath.sqrt(r2)), position);
73
74 }
75
76
77
78
79 public double getMu() {
80 return mu;
81 }
82
83
84 public double getParameter(final String name)
85 throws IllegalArgumentException {
86 complainIfNotSupported(name);
87 return mu;
88 }
89
90
91 public void setParameter(final String name, final double value)
92 throws IllegalArgumentException {
93 complainIfNotSupported(name);
94 this.mu = value;
95 }
96
97
98 public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder)
99 throws OrekitException {
100 adder.addKeplerContribution(mu);
101 }
102
103
104 public EventDetector[] getEventsDetectors() {
105 return new EventDetector[0];
106 }
107
108 }
109