1 /* Copyright 2022-2025 Luc Maisonobe
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.orekit.utils;
19
20 import org.hipparchus.CalculusFieldElement;
21 import org.orekit.frames.FieldStaticTransform;
22 import org.orekit.frames.FieldTransform;
23 import org.orekit.frames.Frame;
24 import org.orekit.frames.StaticTransform;
25 import org.orekit.frames.Transform;
26 import org.orekit.frames.TransformProvider;
27 import org.orekit.time.AbsoluteDate;
28 import org.orekit.time.FieldAbsoluteDate;
29
30 /** Adapter from {@link ExtendedPositionProvider} to {@link TransformProvider}.
31 * <p>
32 * The transform provider is a simple translation from a defining frame such
33 * that the origin of the transformed frame corresponds to the moving point.
34 * </p>
35 * <p>
36 * This class is roughly the inverse of {@link FrameAdapter}
37 * </p>
38 * @see FrameAdapter
39 * @since 12.0
40 * @author Luc Maisonobe
41 */
42 public class ExtendedPositionProviderAdapter extends Frame {
43
44 /** Simple constructor.
45 * @param parent parent frame (must be non-null)
46 * @param provider coordinates provider defining the position of origin of the transformed frame
47 * @param name name of the frame
48 */
49 public ExtendedPositionProviderAdapter(final Frame parent,
50 final ExtendedPositionProvider provider,
51 final String name) {
52 super(parent, new TransformProvider() {
53
54 /** {@inheritDoc} */
55 @Override
56 public StaticTransform getStaticTransform(final AbsoluteDate date) {
57 return StaticTransform.of(date, provider.getPosition(date, parent).negate());
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
63 return FieldStaticTransform.of(date, provider.getPosition(date, parent).negate());
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public Transform getTransform(final AbsoluteDate date) {
69 return new Transform(date, provider.getPVCoordinates(date, parent).negate());
70 }
71
72 /** {@inheritDoc} */
73 @Override
74 public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
75 return new FieldTransform<>(date, provider.getPVCoordinates(date, parent).negate());
76 }
77
78 }, name);
79 }
80
81 }