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.Field;
21 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
22 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
23 import org.hipparchus.geometry.euclidean.threed.Rotation;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.orekit.bodies.BodyShape;
26 import org.orekit.bodies.FieldGeodeticPoint;
27 import org.orekit.bodies.GeodeticPoint;
28 import org.orekit.time.AbsoluteDate;
29 import org.orekit.time.FieldAbsoluteDate;
30
31
32
33
34
35
36 public class TopocentricTransformProvider implements TransformProvider {
37
38
39 private final GeodeticPoint geodeticPoint;
40
41
42 private final BodyShape bodyShape;
43
44
45
46
47
48
49 public TopocentricTransformProvider(final GeodeticPoint geodeticPoint, final BodyShape bodyShape) {
50 this.geodeticPoint = geodeticPoint;
51 this.bodyShape = bodyShape;
52 }
53
54
55
56
57
58 public BodyShape getBodyShape() {
59 return bodyShape;
60 }
61
62 @Override
63 public StaticTransform getStaticTransform(final AbsoluteDate date) {
64 return StaticTransform.of(date, buildTranslation(), buildRotation(geodeticPoint));
65 }
66
67 @Override
68 public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
69 final Field<T> field = date.getField();
70 final FieldGeodeticPoint<T> fieldGeodeticPoint = new FieldGeodeticPoint<>(field, geodeticPoint);
71 return FieldStaticTransform.of(date, buildFieldTranslation(bodyShape, fieldGeodeticPoint),
72 buildFieldRotation(fieldGeodeticPoint));
73 }
74
75 @Override
76 public Transform getTransform(final AbsoluteDate date) {
77 return new Transform(date, buildTranslation(), buildRotation(geodeticPoint));
78 }
79
80 private Vector3D buildTranslation() {
81 return bodyShape.transform(geodeticPoint).negate();
82 }
83
84 @Override
85 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
86 final Field<T> field = date.getField();
87 final FieldGeodeticPoint<T> fieldGeodeticPoint = new FieldGeodeticPoint<>(field, geodeticPoint);
88 return getTransform(bodyShape, date, fieldGeodeticPoint);
89 }
90
91
92
93
94
95
96
97
98
99 public static <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final BodyShape shape,
100 final FieldAbsoluteDate<T> date,
101 final FieldGeodeticPoint<T> fieldGeodeticPoint) {
102 return new FieldTransform<>(date, buildFieldTranslation(shape, fieldGeodeticPoint),
103 buildFieldRotation(fieldGeodeticPoint));
104 }
105
106 private static <T extends CalculusFieldElement<T>> FieldVector3D<T> buildFieldTranslation(final BodyShape shape,
107 final FieldGeodeticPoint<T> fieldGeodeticPoint) {
108 return shape.transform(fieldGeodeticPoint).negate();
109 }
110
111 private static Rotation buildRotation(final GeodeticPoint point) {
112 return new Rotation(point.getEast(), point.getZenith(), Vector3D.PLUS_I, Vector3D.PLUS_K);
113 }
114
115 private static <W extends CalculusFieldElement<W>> FieldRotation<W> buildFieldRotation(final FieldGeodeticPoint<W> fieldGeodeticPoint) {
116 final Field<W> field = fieldGeodeticPoint.getAltitude().getField();
117 return new FieldRotation<>(fieldGeodeticPoint.getEast(), fieldGeodeticPoint.getZenith(),
118 FieldVector3D.getPlusI(field), FieldVector3D.getPlusK(field));
119 }
120 }