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.FieldVector3D;
24 import org.hipparchus.geometry.euclidean.threed.Rotation;
25 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
26 import org.hipparchus.geometry.euclidean.threed.Vector3D;
27 import org.orekit.annotation.DefaultDataContext;
28 import org.orekit.data.DataContext;
29 import org.orekit.errors.OrekitException;
30 import org.orekit.errors.OrekitInternalError;
31 import org.orekit.time.AbsoluteDate;
32 import org.orekit.time.FieldAbsoluteDate;
33 import org.orekit.time.TimeScalarFunction;
34 import org.orekit.time.TimeScale;
35 import org.orekit.time.TimeScales;
36 import org.orekit.utils.Constants;
37 import org.orekit.utils.IERSConventions;
38
39
40
41
42
43
44
45
46
47 public class GTODProvider implements EOPBasedTransformProvider {
48
49
50 private static final long serialVersionUID = 20141228L;
51
52
53 private static final double AVE = 7.292115146706979e-5;
54
55
56 private final IERSConventions conventions;
57
58
59 private final EOPHistory eopHistory;
60
61
62 private final transient TimeScalarFunction gastFunction;
63
64
65
66
67
68
69
70 protected GTODProvider(final IERSConventions conventions,
71 final EOPHistory eopHistory,
72 final TimeScales timeScales) {
73 final TimeScale ut1 = eopHistory == null ?
74 timeScales.getUTC() :
75 timeScales.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
76 this.conventions = conventions;
77 this.eopHistory = eopHistory;
78 this.gastFunction = conventions.getGASTFunction(ut1, eopHistory, timeScales);
79 }
80
81
82
83
84
85
86
87
88 private GTODProvider(final IERSConventions conventions,
89 final EOPHistory eopHistory,
90 final TimeScalarFunction gastFunction) {
91 this.conventions = conventions;
92 this.eopHistory = eopHistory;
93 this.gastFunction = gastFunction;
94 }
95
96
97 @Override
98 public EOPHistory getEOPHistory() {
99 return eopHistory;
100 }
101
102
103 @Override
104 public GTODProvider getNonInterpolatingProvider() {
105 return new GTODProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
106 gastFunction);
107 }
108
109
110 @Override
111 public Transform getTransform(final AbsoluteDate date) {
112
113
114 final double gast = gastFunction.value(date);
115
116
117 final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
118 final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
119 final Vector3D rotationRate = new Vector3D(omp, Vector3D.PLUS_K);
120
121
122 return new Transform(date, new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM), rotationRate);
123
124 }
125
126
127 @Override
128 public StaticTransform getStaticTransform(final AbsoluteDate date) {
129
130
131 final double gast = gastFunction.value(date);
132
133
134 return StaticTransform.of(
135 date,
136 new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM));
137
138 }
139
140
141 @Override
142 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
143
144
145 final T gast = gastFunction.value(date);
146
147
148 final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
149 final T omp = lod.multiply(-1.0 / Constants.JULIAN_DAY).add(1).multiply(AVE);
150 final FieldVector3D<T> rotationRate = new FieldVector3D<>(date.getField().getZero(),
151 date.getField().getZero(),
152 date.getField().getZero().add(omp));
153
154
155 return new FieldTransform<>(date,
156 new FieldRotation<>(FieldVector3D.getPlusK(date.getField()),
157 gast, RotationConvention.FRAME_TRANSFORM),
158 rotationRate);
159
160 }
161
162
163 @Override
164 public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
165
166
167 final T gast = gastFunction.value(date);
168
169
170 return FieldStaticTransform.of(
171 date,
172 new FieldRotation<>(FieldVector3D.getPlusK(date.getField()), gast, RotationConvention.FRAME_TRANSFORM));
173
174 }
175
176
177
178
179
180
181
182 @DefaultDataContext
183 private Object writeReplace() {
184 return new DataTransferObject(conventions, eopHistory);
185 }
186
187
188 @DefaultDataContext
189 private static class DataTransferObject implements Serializable {
190
191
192 private static final long serialVersionUID = 20131209L;
193
194
195 private final IERSConventions conventions;
196
197
198 private final EOPHistory eopHistory;
199
200
201
202
203
204 DataTransferObject(final IERSConventions conventions, final EOPHistory eopHistory) {
205 this.conventions = conventions;
206 this.eopHistory = eopHistory;
207 }
208
209
210
211
212 private Object readResolve() {
213 try {
214
215 return new GTODProvider(conventions, eopHistory,
216 DataContext.getDefault().getTimeScales());
217 } catch (OrekitException oe) {
218 throw new OrekitInternalError(oe);
219 }
220 }
221
222 }
223
224 }