1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.forces.inertia;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
21 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
22 import org.hipparchus.geometry.euclidean.threed.Rotation;
23 import org.hipparchus.geometry.euclidean.threed.Vector3D;
24 import org.orekit.errors.OrekitIllegalArgumentException;
25 import org.orekit.errors.OrekitMessages;
26 import org.orekit.forces.ForceModel;
27 import org.orekit.frames.FieldTransform;
28 import org.orekit.frames.Frame;
29 import org.orekit.frames.Transform;
30 import org.orekit.propagation.FieldSpacecraftState;
31 import org.orekit.propagation.SpacecraftState;
32 import org.orekit.utils.AbsolutePVCoordinates;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 public class InertialForces implements ForceModel {
61
62
63 private final Frame referenceInertialFrame;
64
65
66
67
68
69
70 public InertialForces(final Frame referenceInertialFrame)
71 throws OrekitIllegalArgumentException {
72 if (!referenceInertialFrame.isPseudoInertial()) {
73 throw new OrekitIllegalArgumentException(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME_NOT_SUITABLE_AS_REFERENCE_FOR_INERTIAL_FORCES,
74 referenceInertialFrame.getName());
75 }
76 this.referenceInertialFrame = referenceInertialFrame;
77 }
78
79
80 @Override
81 public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
82
83 final Transform inertToStateFrame = referenceInertialFrame.getTransformTo(s.getFrame(), s.getDate());
84 final Vector3D a1 = inertToStateFrame.getCartesian().getAcceleration();
85 final Rotation r1 = inertToStateFrame.getAngular().getRotation();
86 final Vector3D o1 = inertToStateFrame.getAngular().getRotationRate();
87 final Vector3D oDot1 = inertToStateFrame.getAngular().getRotationAcceleration();
88
89 final Vector3D p2 = s.getPosition();
90 final Vector3D v2 = s.getVelocity();
91
92 final Vector3D crossCrossP = Vector3D.crossProduct(o1, Vector3D.crossProduct(o1, p2));
93 final Vector3D crossV = Vector3D.crossProduct(o1, v2);
94 final Vector3D crossDotP = Vector3D.crossProduct(oDot1, p2);
95
96
97
98 return r1.applyTo(a1).subtract(new Vector3D(2, crossV, 1, crossCrossP, 1, crossDotP));
99
100 }
101
102
103 @Override
104 public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
105 final T[] parameters) {
106
107 final FieldTransform<T> inertToStateFrame = referenceInertialFrame.getTransformTo(s.getFrame(), s.getDate());
108 final FieldVector3D<T> a1 = inertToStateFrame.getCartesian().getAcceleration();
109 final FieldRotation<T> r1 = inertToStateFrame.getAngular().getRotation();
110 final FieldVector3D<T> o1 = inertToStateFrame.getAngular().getRotationRate();
111 final FieldVector3D<T> oDot1 = inertToStateFrame.getAngular().getRotationAcceleration();
112
113 final FieldVector3D<T> p2 = s.getPosition();
114 final FieldVector3D<T> v2 = s.getVelocity();
115
116 final FieldVector3D<T> crossCrossP = FieldVector3D.crossProduct(o1, FieldVector3D.crossProduct(o1, p2));
117 final FieldVector3D<T> crossV = FieldVector3D.crossProduct(o1, v2);
118 final FieldVector3D<T> crossDotP = FieldVector3D.crossProduct(oDot1, p2);
119
120
121
122 return r1.applyTo(a1).subtract(new FieldVector3D<>(2, crossV, 1, crossCrossP, 1, crossDotP));
123
124 }
125
126 }