1 /* Copyright 2002-2024 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.Frame;
22 import org.orekit.time.AbsoluteDate;
23 import org.orekit.time.FieldAbsoluteDate;
24
25 /** Adapter from {@link Frame} to {@link ExtendedPVCoordinatesProvider}.
26 * <p>
27 * The moving point is the origin of the adapted frame.
28 * </p>
29 * <p>
30 * This class is roughly the inverse of {@link ExtendedPVCoordinatesProviderAdapter}
31 * </p>
32 * @see ExtendedPVCoordinatesProviderAdapter
33 * @since 12.0
34 * @author Luc Maisonobe
35 */
36 public class FrameAdapter implements ExtendedPVCoordinatesProvider {
37
38 /** Frame whose origin coordinates are desired. */
39 private final Frame originFrame;
40
41 /** Simple constructor.
42 * @param originFrame frame whose origin coordinates are desired
43 */
44 public FrameAdapter(final Frame originFrame) {
45 this.originFrame = originFrame;
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
51 return new TimeStampedPVCoordinates(date,
52 originFrame.
53 getTransformTo(frame, date).
54 transformPVCoordinates(PVCoordinates.ZERO));
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public <T extends CalculusFieldElement<T>> TimeStampedFieldPVCoordinates<T> getPVCoordinates(final FieldAbsoluteDate<T> date,
60 final Frame frame) {
61 return new TimeStampedFieldPVCoordinates<>(date,
62 originFrame.
63 getTransformTo(frame, date).
64 transformPVCoordinates(PVCoordinates.ZERO));
65 }
66
67 }