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.util.HashMap;
20 import java.util.Map;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.Field;
24 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
25 import org.hipparchus.geometry.euclidean.threed.Rotation;
26 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
27 import org.hipparchus.geometry.euclidean.threed.RotationOrder;
28 import org.hipparchus.geometry.euclidean.threed.Vector3D;
29 import org.orekit.time.AbsoluteDate;
30 import org.orekit.time.FieldAbsoluteDate;
31 import org.orekit.time.TimeScalarFunction;
32 import org.orekit.time.TimeScales;
33 import org.orekit.time.TimeVectorFunction;
34 import org.orekit.utils.IERSConventions;
35
36
37
38
39
40
41
42 class MODProvider implements FieldBasedTransformProvider {
43
44
45 private final TimeVectorFunction precessionFunction;
46
47
48 private final Rotation r4;
49
50
51 private final Map<Field<? extends CalculusFieldElement<?>>, FieldRotation<? extends CalculusFieldElement<?>>> fieldR4;
52
53
54
55
56
57 MODProvider(final IERSConventions conventions, final TimeScales timeScales) {
58 this.precessionFunction = conventions.getPrecessionFunction(timeScales);
59 final TimeScalarFunction epsilonAFunction =
60 conventions.getMeanObliquityFunction(timeScales);
61 final AbsoluteDate date0 = conventions.getNutationReferenceEpoch(timeScales);
62 final double epsilon0 = epsilonAFunction.value(date0);
63 r4 = new Rotation(Vector3D.PLUS_I, epsilon0, RotationConvention.FRAME_TRANSFORM);
64 fieldR4 = new HashMap<>();
65 }
66
67
68
69
70
71
72 public <T extends CalculusFieldElement<T>> FieldRotation<T> getRotation(final FieldAbsoluteDate<T> date) {
73
74
75 final T[] angles = precessionFunction.value(date);
76
77
78 return getR4(date.getField()).compose(
79 new FieldRotation<>(RotationOrder.ZXZ, RotationConvention.FRAME_TRANSFORM,
80 angles[0].negate(), angles[1].negate(), angles[2]),
81 RotationConvention.FRAME_TRANSFORM);
82
83 }
84
85
86
87
88
89
90 @SuppressWarnings("unchecked")
91 private <T extends CalculusFieldElement<T>> FieldRotation<T> getR4(final Field<T> field) {
92 synchronized (fieldR4) {
93 return (FieldRotation<T>) fieldR4.computeIfAbsent(field, f -> new FieldRotation<>(field, r4));
94 }
95 }
96
97 }