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.RealFieldElement;
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
71
72
73
74 @Deprecated
75 @DefaultDataContext
76 protected GTODProvider(final IERSConventions conventions,
77 final EOPHistory eopHistory) {
78 this(conventions, eopHistory,
79 eopHistory == null ?
80 DataContext.getDefault().getTimeScales() :
81 eopHistory.getTimeScales());
82 }
83
84
85
86
87
88
89
90 protected GTODProvider(final IERSConventions conventions,
91 final EOPHistory eopHistory,
92 final TimeScales timeScales) {
93 final TimeScale ut1 = eopHistory == null ?
94 timeScales.getUTC() :
95 timeScales.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
96 this.conventions = conventions;
97 this.eopHistory = eopHistory;
98 this.gastFunction = conventions.getGASTFunction(ut1, eopHistory, timeScales);
99 }
100
101
102
103
104
105
106
107
108 private GTODProvider(final IERSConventions conventions,
109 final EOPHistory eopHistory,
110 final TimeScalarFunction gastFunction) {
111 this.conventions = conventions;
112 this.eopHistory = eopHistory;
113 this.gastFunction = gastFunction;
114 }
115
116
117 @Override
118 public EOPHistory getEOPHistory() {
119 return eopHistory;
120 }
121
122
123 @Override
124 public GTODProvider getNonInterpolatingProvider() {
125 return new GTODProvider(conventions, eopHistory.getNonInterpolatingEOPHistory(),
126 gastFunction);
127 }
128
129
130 @Override
131 public Transform getTransform(final AbsoluteDate date) {
132
133
134 final double gast = gastFunction.value(date);
135
136
137 final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
138 final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
139 final Vector3D rotationRate = new Vector3D(omp, Vector3D.PLUS_K);
140
141
142 return new Transform(date, new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM), rotationRate);
143
144 }
145
146
147 @Override
148 public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
149
150
151 final T gast = gastFunction.value(date);
152
153
154 final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
155 final T omp = lod.multiply(-1.0 / Constants.JULIAN_DAY).add(1).multiply(AVE);
156 final FieldVector3D<T> rotationRate = new FieldVector3D<>(date.getField().getZero(),
157 date.getField().getZero(),
158 date.getField().getZero().add(omp));
159
160
161 return new FieldTransform<>(date,
162 new FieldRotation<>(FieldVector3D.getPlusK(date.getField()),
163 gast, RotationConvention.FRAME_TRANSFORM),
164 rotationRate);
165
166 }
167
168
169
170
171
172
173
174 @DefaultDataContext
175 private Object writeReplace() {
176 return new DataTransferObject(conventions, eopHistory);
177 }
178
179
180 @DefaultDataContext
181 private static class DataTransferObject implements Serializable {
182
183
184 private static final long serialVersionUID = 20131209L;
185
186
187 private final IERSConventions conventions;
188
189
190 private final EOPHistory eopHistory;
191
192
193
194
195
196 DataTransferObject(final IERSConventions conventions, final EOPHistory eopHistory) {
197 this.conventions = conventions;
198 this.eopHistory = eopHistory;
199 }
200
201
202
203
204 private Object readResolve() {
205 try {
206
207 return new GTODProvider(conventions, eopHistory,
208 DataContext.getDefault().getTimeScales());
209 } catch (OrekitException oe) {
210 throw new OrekitInternalError(oe);
211 }
212 }
213
214 }
215
216 }