1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.frames;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
21 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
22 import org.hipparchus.geometry.euclidean.threed.Rotation;
23 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.orekit.time.AbsoluteDate;
26 import org.orekit.time.FieldAbsoluteDate;
27 import org.orekit.time.TimeScalarFunction;
28 import org.orekit.time.TimeScale;
29 import org.orekit.time.TimeScales;
30 import org.orekit.utils.Constants;
31 import org.orekit.utils.IERSConventions;
32
33
34
35
36
37
38
39
40
41 public class GTODProvider implements EOPBasedTransformProvider {
42
43
44 private static final double AVE = 7.292115146706979e-5;
45
46
47 private final IERSConventions conventions;
48
49
50 private final EOPHistory eopHistory;
51
52
53 private final TimeScalarFunction gastFunction;
54
55
56
57
58
59
60
61 protected GTODProvider(final IERSConventions conventions,
62 final EOPHistory eopHistory,
63 final TimeScales timeScales) {
64 final TimeScale ut1 = eopHistory == null ?
65 timeScales.getUTC() :
66 timeScales.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
67 this.conventions = conventions;
68 this.eopHistory = eopHistory;
69 this.gastFunction = conventions.getGASTFunction(ut1, eopHistory, timeScales);
70 }
71
72
73
74
75
76
77
78
79 private GTODProvider(final IERSConventions conventions,
80 final EOPHistory eopHistory,
81 final TimeScalarFunction gastFunction) {
82 this.conventions = conventions;
83 this.eopHistory = eopHistory;
84 this.gastFunction = gastFunction;
85 }
86
87
88 @Override
89 public EOPHistory getEOPHistory() {
90 return eopHistory;
91 }
92
93
94 @Override
95 public GTODProvider getNonInterpolatingProvider() {
96 return new GTODProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
97 gastFunction);
98 }
99
100
101 @Override
102 public Transform getTransform(final AbsoluteDate date) {
103 return new Transform(date, getRotation(date), getRotationRate(date));
104 }
105
106
107 @Override
108 public KinematicTransform getKinematicTransform(final AbsoluteDate date) {
109 return KinematicTransform.of(date, getRotation(date), getRotationRate(date));
110 }
111
112
113 @Override
114 public StaticTransform getStaticTransform(final AbsoluteDate date) {
115 return StaticTransform.of(date, getRotation(date));
116 }
117
118
119
120
121
122
123 private Rotation getRotation(final AbsoluteDate date) {
124
125 final double gast = gastFunction.value(date);
126
127
128 return new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM);
129 }
130
131
132
133
134
135
136 private Vector3D getRotationRate(final AbsoluteDate date) {
137
138 final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
139 final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
140 return new Vector3D(omp, Vector3D.PLUS_K);
141 }
142
143
144 @Override
145 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
146 return new FieldTransform<>(date, getRotation(date), getRotationRate(date));
147 }
148
149
150 @Override
151 public <T extends CalculusFieldElement<T>> FieldKinematicTransform<T> getKinematicTransform(final FieldAbsoluteDate<T> date) {
152 return FieldKinematicTransform.of(date, getRotation(date), getRotationRate(date));
153 }
154
155
156 @Override
157 public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
158 return FieldStaticTransform.of(date, getRotation(date));
159 }
160
161
162
163
164
165
166
167 private <T extends CalculusFieldElement<T>> FieldRotation<T> getRotation(final FieldAbsoluteDate<T> date) {
168
169 final T gast = gastFunction.value(date);
170
171
172 return new FieldRotation<>(FieldVector3D.getPlusK(date.getField()), gast, RotationConvention.FRAME_TRANSFORM);
173 }
174
175
176
177
178
179
180
181 private <T extends CalculusFieldElement<T>> FieldVector3D<T> getRotationRate(final FieldAbsoluteDate<T> date) {
182
183 final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
184 final T omp = lod.multiply(-1.0 / Constants.JULIAN_DAY).add(1).multiply(AVE);
185 return new FieldVector3D<>(date.getField().getZero(),
186 date.getField().getZero(),
187 date.getField().getZero().add(omp));
188 }
189
190 }