1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19 import java.io.Serializable;
20
21 import org.hipparchus.CalculusFieldElement;
22 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
23 import org.hipparchus.geometry.euclidean.threed.Rotation;
24 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
25 import org.hipparchus.geometry.euclidean.threed.RotationOrder;
26 import org.orekit.annotation.DefaultDataContext;
27 import org.orekit.data.DataContext;
28 import org.orekit.errors.OrekitException;
29 import org.orekit.errors.OrekitInternalError;
30 import org.orekit.time.AbsoluteDate;
31 import org.orekit.time.FieldAbsoluteDate;
32 import org.orekit.time.TimeScalarFunction;
33 import org.orekit.time.TimeScales;
34 import org.orekit.time.TimeVectorFunction;
35 import org.orekit.utils.IERSConventions;
36
37
38
39
40
41
42 class TODProvider implements EOPBasedTransformProvider {
43
44
45 private static final long serialVersionUID = 20131209L;
46
47
48 private final IERSConventions conventions;
49
50
51 private final EOPHistory eopHistory;
52
53
54 private final transient TimeScalarFunction obliquityFunction;
55
56
57 private final transient TimeVectorFunction nutationFunction;
58
59
60
61
62
63
64
65
66
67 TODProvider(final IERSConventions conventions,
68 final EOPHistory eopHistory,
69 final TimeScales timeScales) {
70 this.conventions = conventions;
71 this.eopHistory = eopHistory;
72 this.obliquityFunction = conventions.getMeanObliquityFunction(timeScales);
73 this.nutationFunction =
74 conventions.getNutationFunction(timeScales);
75 }
76
77
78
79
80
81
82
83
84
85 private TODProvider(final IERSConventions conventions,
86 final EOPHistory eopHistory,
87 final TimeScalarFunction obliquityFunction,
88 final TimeVectorFunction nutationFunction) {
89 this.conventions = conventions;
90 this.eopHistory = eopHistory;
91 this.obliquityFunction = obliquityFunction;
92 this.nutationFunction = nutationFunction;
93 }
94
95
96 @Override
97 public EOPHistory getEOPHistory() {
98 return eopHistory;
99 }
100
101
102 @Override
103 public TODProvider getNonInterpolatingProvider() {
104 return new TODProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
105 obliquityFunction, nutationFunction);
106 }
107
108
109 @Override
110 public Transform getTransform(final AbsoluteDate date) {
111
112
113 final double[] angles = nutationFunction.value(date);
114
115
116 final double moe = obliquityFunction.value(date);
117
118 double dpsi = angles[0];
119 double deps = angles[1];
120 if (eopHistory != null) {
121
122 final double[] correction = eopHistory.getEquinoxNutationCorrection(date);
123 dpsi += correction[0];
124 deps += correction[1];
125 }
126
127
128 final double toe = moe + deps;
129
130
131 final Rotation nutation = new Rotation(RotationOrder.XZX, RotationConvention.FRAME_TRANSFORM,
132 moe, -dpsi, -toe);
133
134
135 return new Transform(date, nutation);
136
137 }
138
139
140
141 @Override
142 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
143
144
145 final T[] angles = nutationFunction.value(date);
146
147
148 final T moe = obliquityFunction.value(date);
149
150 T dpsi = angles[0];
151 T deps = angles[1];
152 if (eopHistory != null) {
153
154 final T[] correction = eopHistory.getEquinoxNutationCorrection(date);
155 dpsi = dpsi.add(correction[0]);
156 deps = deps.add(correction[1]);
157 }
158
159
160 final T toe = moe.add(deps);
161
162
163 final FieldRotation<T> nutation = new FieldRotation<>(RotationOrder.XZX, RotationConvention.FRAME_TRANSFORM,
164 moe, dpsi.negate(), toe.negate());
165
166
167 return new FieldTransform<>(date, nutation);
168
169 }
170
171
172
173
174
175
176
177 @DefaultDataContext
178 private Object writeReplace() {
179 return new DataTransferObject(conventions, eopHistory);
180 }
181
182
183 @DefaultDataContext
184 private static class DataTransferObject implements Serializable {
185
186
187 private static final long serialVersionUID = 20131209L;
188
189
190 private final IERSConventions conventions;
191
192
193 private final EOPHistory eopHistory;
194
195
196
197
198
199 DataTransferObject(final IERSConventions conventions, final EOPHistory eopHistory) {
200 this.conventions = conventions;
201 this.eopHistory = eopHistory;
202 }
203
204
205
206
207 private Object readResolve() {
208 try {
209
210 return new TODProvider(conventions, eopHistory,
211 DataContext.getDefault().getTimeScales());
212 } catch (OrekitException oe) {
213 throw new OrekitInternalError(oe);
214 }
215 }
216
217 }
218
219 }