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.getNonInterpolatingEOPHistory(),
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 <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
129
130
131 final T gast = gastFunction.value(date);
132
133
134 final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
135 final T omp = lod.multiply(-1.0 / Constants.JULIAN_DAY).add(1).multiply(AVE);
136 final FieldVector3D<T> rotationRate = new FieldVector3D<>(date.getField().getZero(),
137 date.getField().getZero(),
138 date.getField().getZero().add(omp));
139
140
141 return new FieldTransform<>(date,
142 new FieldRotation<>(FieldVector3D.getPlusK(date.getField()),
143 gast, RotationConvention.FRAME_TRANSFORM),
144 rotationRate);
145
146 }
147
148
149
150
151
152
153
154 @DefaultDataContext
155 private Object writeReplace() {
156 return new DataTransferObject(conventions, eopHistory);
157 }
158
159
160 @DefaultDataContext
161 private static class DataTransferObject implements Serializable {
162
163
164 private static final long serialVersionUID = 20131209L;
165
166
167 private final IERSConventions conventions;
168
169
170 private final EOPHistory eopHistory;
171
172
173
174
175
176 DataTransferObject(final IERSConventions conventions, final EOPHistory eopHistory) {
177 this.conventions = conventions;
178 this.eopHistory = eopHistory;
179 }
180
181
182
183
184 private Object readResolve() {
185 try {
186
187 return new GTODProvider(conventions, eopHistory,
188 DataContext.getDefault().getTimeScales());
189 } catch (OrekitException oe) {
190 throw new OrekitInternalError(oe);
191 }
192 }
193
194 }
195
196 }