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.Line;
23 import org.hipparchus.geometry.euclidean.threed.Rotation;
24 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
25 import org.hipparchus.geometry.euclidean.threed.Vector3D;
26 import org.orekit.time.AbsoluteDate;
27 import org.orekit.time.TimeStamped;
28
29
30
31
32
33
34
35
36
37 public interface StaticTransform extends TimeStamped {
38
39
40
41
42
43
44
45 static StaticTransform getIdentity() {
46 return new StaticTransform() {
47 @Override
48 public Vector3D getTranslation() {
49 return Vector3D.ZERO;
50 }
51
52 @Override
53 public Rotation getRotation() {
54 return Rotation.IDENTITY;
55 }
56
57 @Override
58 public StaticTransform getStaticInverse() {
59 return getInverse();
60 }
61
62 @Override
63 public StaticTransform getInverse() {
64 return this;
65 }
66
67 @Override
68 public AbsoluteDate getDate() {
69 return AbsoluteDate.ARBITRARY_EPOCH;
70 }
71
72 @Override
73 public Vector3D transformPosition(final Vector3D position) {
74 return transformVector(position);
75 }
76
77 @Override
78 public Vector3D transformVector(final Vector3D vector) {
79 return new Vector3D(vector.getX(), vector.getY(), vector.getZ());
80 }
81
82 @Override
83 public <T extends CalculusFieldElement<T>> FieldVector3D<T> transformVector(final FieldVector3D<T> vector) {
84 return new FieldVector3D<>(vector.getX(), vector.getY(), vector.getZ());
85 }
86
87 @Override
88 public <T extends CalculusFieldElement<T>> FieldVector3D<T> transformPosition(final FieldVector3D<T> position) {
89 return transformVector(position);
90 }
91 };
92 }
93
94
95
96
97
98
99
100 default Vector3D transformPosition(final Vector3D position) {
101 return getRotation().applyTo(getTranslation().add(position));
102 }
103
104
105
106
107
108
109
110
111 default <T extends CalculusFieldElement<T>> FieldVector3D<T> transformPosition(
112 final FieldVector3D<T> position) {
113 return FieldRotation.applyTo(getRotation(), position.add(getTranslation()));
114 }
115
116
117
118
119
120
121
122 default Vector3D transformVector(final Vector3D vector) {
123 return getRotation().applyTo(vector);
124 }
125
126
127
128
129
130
131
132
133 default <T extends CalculusFieldElement<T>> FieldVector3D<T> transformVector(
134 final FieldVector3D<T> vector) {
135 return FieldRotation.applyTo(getRotation(), vector);
136 }
137
138
139
140
141
142
143
144 default Line transformLine(final Line line) {
145 final Vector3D transformedP0 = transformPosition(line.getOrigin());
146 final Vector3D transformedD = transformVector(line.getDirection());
147 return Line.fromDirection(transformedP0, transformedD, line.getTolerance());
148 }
149
150
151
152
153
154
155
156
157
158 Vector3D getTranslation();
159
160
161
162
163
164
165
166
167
168 Rotation getRotation();
169
170
171
172
173
174
175 StaticTransform getInverse();
176
177
178
179
180
181
182
183
184
185 default StaticTransform getStaticInverse() {
186 final Rotation rotation = getRotation();
187 return StaticTransform.of(getDate(), rotation.applyTo(getTranslation()).negate(), rotation.revert());
188 }
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 static StaticTransform compose(final AbsoluteDate date,
207 final StaticTransform first,
208 final StaticTransform second) {
209 return of(date,
210 compositeTranslation(first, second),
211 compositeRotation(first, second));
212 }
213
214
215
216
217
218
219
220
221 static Vector3D compositeTranslation(
222 final StaticTransform first,
223 final StaticTransform second) {
224 final Vector3D p1 = first.getTranslation();
225 final Rotation r1 = first.getRotation();
226 final Vector3D p2 = second.getTranslation();
227
228 return p1.add(r1.applyInverseTo(p2));
229 }
230
231
232
233
234
235
236
237
238 static Rotation compositeRotation(final StaticTransform first,
239 final StaticTransform second) {
240 final Rotation r1 = first.getRotation();
241 final Rotation r2 = second.getRotation();
242 return r1.compose(r2, RotationConvention.FRAME_TRANSFORM);
243
244 }
245
246
247
248
249
250
251
252
253
254
255
256 static StaticTransform of(final AbsoluteDate date,
257 final Rotation rotation) {
258 return of(date, Vector3D.ZERO, rotation);
259 }
260
261
262
263
264
265
266
267
268
269
270
271 static StaticTransform of(final AbsoluteDate date,
272 final Vector3D translation) {
273 return of(date, translation, Rotation.IDENTITY);
274 }
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291 static StaticTransform of(final AbsoluteDate date,
292 final Vector3D translation,
293 final Rotation rotation) {
294 return new StaticTransform() {
295
296 @Override
297 public StaticTransform getInverse() {
298 final Rotation r = getRotation();
299 final Vector3D rp = r.applyTo(getTranslation());
300 final Vector3D pInv = rp.negate();
301 return StaticTransform.of(date, pInv, rotation.revert());
302 }
303
304 @Override
305 public AbsoluteDate getDate() {
306 return date;
307 }
308
309 @Override
310 public Vector3D getTranslation() {
311 return translation;
312 }
313
314 @Override
315 public Rotation getRotation() {
316 return rotation;
317 }
318
319 };
320 }
321
322 }