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.Rotation;
22 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
23 import org.hipparchus.geometry.euclidean.threed.RotationOrder;
24 import org.orekit.time.AbsoluteDate;
25 import org.orekit.time.FieldAbsoluteDate;
26 import org.orekit.time.TimeScalarFunction;
27 import org.orekit.time.TimeScales;
28 import org.orekit.time.TimeVectorFunction;
29 import org.orekit.utils.IERSConventions;
30
31
32
33
34
35
36 class TODProvider implements EOPBasedTransformProvider {
37
38
39 private final IERSConventions conventions;
40
41
42 private final EOPHistory eopHistory;
43
44
45 private final TimeScalarFunction obliquityFunction;
46
47
48 private final TimeVectorFunction nutationFunction;
49
50
51
52
53
54
55
56
57
58 TODProvider(final IERSConventions conventions,
59 final EOPHistory eopHistory,
60 final TimeScales timeScales) {
61 this.conventions = conventions;
62 this.eopHistory = eopHistory;
63 this.obliquityFunction = conventions.getMeanObliquityFunction(timeScales);
64 this.nutationFunction =
65 conventions.getNutationFunction(timeScales);
66 }
67
68
69
70
71
72
73
74
75
76 private TODProvider(final IERSConventions conventions,
77 final EOPHistory eopHistory,
78 final TimeScalarFunction obliquityFunction,
79 final TimeVectorFunction nutationFunction) {
80 this.conventions = conventions;
81 this.eopHistory = eopHistory;
82 this.obliquityFunction = obliquityFunction;
83 this.nutationFunction = nutationFunction;
84 }
85
86
87 @Override
88 public EOPHistory getEOPHistory() {
89 return eopHistory;
90 }
91
92
93 @Override
94 public TODProvider getNonInterpolatingProvider() {
95 return new TODProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
96 obliquityFunction, nutationFunction);
97 }
98
99
100 @Override
101 public Transform getTransform(final AbsoluteDate date) {
102
103
104 final double[] angles = nutationFunction.value(date);
105
106
107 final double moe = obliquityFunction.value(date);
108
109 double dpsi = angles[0];
110 double deps = angles[1];
111 if (eopHistory != null) {
112
113 final double[] correction = eopHistory.getEquinoxNutationCorrection(date);
114 dpsi += correction[0];
115 deps += correction[1];
116 }
117
118
119 final double toe = moe + deps;
120
121
122 final Rotation nutation = new Rotation(RotationOrder.XZX, RotationConvention.FRAME_TRANSFORM,
123 moe, -dpsi, -toe);
124
125
126 return new Transform(date, nutation);
127
128 }
129
130
131
132 @Override
133 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
134
135
136 final T[] angles = nutationFunction.value(date);
137
138
139 final T moe = obliquityFunction.value(date);
140
141 T dpsi = angles[0];
142 T deps = angles[1];
143 if (eopHistory != null) {
144
145 final T[] correction = eopHistory.getEquinoxNutationCorrection(date);
146 dpsi = dpsi.add(correction[0]);
147 deps = deps.add(correction[1]);
148 }
149
150
151 final T toe = moe.add(deps);
152
153
154 final FieldRotation<T> nutation = new FieldRotation<>(RotationOrder.XZX, RotationConvention.FRAME_TRANSFORM,
155 moe, dpsi.negate(), toe.negate());
156
157
158 return new FieldTransform<>(date, nutation);
159
160 }
161
162 }