1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19
20 import org.hipparchus.CalculusFieldElement;
21 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
22 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
23 import org.hipparchus.geometry.euclidean.threed.Rotation;
24 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
25 import org.hipparchus.geometry.euclidean.threed.Vector3D;
26 import org.hipparchus.util.FastMath;
27 import org.orekit.time.AbsoluteDate;
28 import org.orekit.time.FieldAbsoluteDate;
29 import org.orekit.time.TimeScalarFunction;
30 import org.orekit.time.TimeScales;
31 import org.orekit.time.TimeVectorFunction;
32 import org.orekit.utils.IERSConventions;
33
34
35
36
37
38
39
40
41
42 class TEMEProvider implements EOPBasedTransformProvider {
43
44
45 private final IERSConventions conventions;
46
47
48 private final EOPHistory eopHistory;
49
50
51 private final TimeScalarFunction obliquityFunction;
52
53
54 private final TimeVectorFunction nutationFunction;
55
56
57
58
59
60
61
62
63 TEMEProvider(final IERSConventions conventions,
64 final EOPHistory eopHistory,
65 final TimeScales timeScales) {
66 this.conventions = conventions;
67 this.eopHistory = eopHistory;
68 this.obliquityFunction = conventions.getMeanObliquityFunction(timeScales);
69 this.nutationFunction = conventions.getNutationFunction(timeScales);
70 }
71
72
73
74
75
76
77
78
79
80 private TEMEProvider(final IERSConventions conventions,
81 final EOPHistory eopHistory,
82 final TimeScalarFunction obliquityFunction,
83 final TimeVectorFunction nutationFunction) {
84 this.conventions = conventions;
85 this.eopHistory = eopHistory;
86 this.obliquityFunction = obliquityFunction;
87 this.nutationFunction = nutationFunction;
88 }
89
90
91 @Override
92 public EOPHistory getEOPHistory() {
93 return eopHistory;
94 }
95
96
97 @Override
98 public TEMEProvider getNonInterpolatingProvider() {
99 return new TEMEProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
100 obliquityFunction, nutationFunction);
101 }
102
103
104 @Override
105 public Transform getTransform(final AbsoluteDate date) {
106 final double eqe = getEquationOfEquinoxes(date);
107 return new Transform(date, new Rotation(Vector3D.PLUS_K, eqe, RotationConvention.FRAME_TRANSFORM));
108 }
109
110
111 @Override
112 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
113 final T eqe = getEquationOfEquinoxes(date);
114 return new FieldTransform<>(date, new FieldRotation<>(FieldVector3D.getPlusK(date.getField()),
115 eqe,
116 RotationConvention.FRAME_TRANSFORM));
117 }
118
119
120
121
122
123 private double getEquationOfEquinoxes(final AbsoluteDate date) {
124
125
126 final double[] angles = nutationFunction.value(date);
127
128
129 double dPsi = angles[0];
130
131 if (eopHistory != null) {
132
133 final double[] correction = eopHistory.getEquinoxNutationCorrection(date);
134 dPsi += correction[0];
135 }
136
137
138 final double moe = obliquityFunction.value(date);
139
140
141 final double eqe = dPsi * FastMath.cos(moe);
142
143
144 return eqe + angles[2];
145
146 }
147
148
149
150
151
152
153 private <T extends CalculusFieldElement<T>> T getEquationOfEquinoxes(final FieldAbsoluteDate<T> date) {
154
155
156 final T[] angles = nutationFunction.value(date);
157
158
159 T dPsi = angles[0];
160
161 if (eopHistory != null) {
162
163 final T[] correction = eopHistory.getEquinoxNutationCorrection(date);
164 dPsi = dPsi.add(correction[0]);
165 }
166
167
168 final T moe = obliquityFunction.value(date);
169
170
171 final T eqe = dPsi.multiply(moe.cos());
172
173
174 return eqe.add(angles[2]);
175
176 }
177
178 }