1 /* Copyright 2002-2025 CS GROUP
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 package org.orekit.orbits;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.orekit.errors.OrekitIllegalArgumentException;
21 import org.orekit.errors.OrekitMessages;
22 import org.orekit.frames.Frame;
23 import org.orekit.time.AbstractFieldTimeInterpolator;
24 import org.orekit.time.FieldAbsoluteDate;
25
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.stream.Collectors;
29
30 /**
31 * Abstract class for orbit interpolator.
32 *
33 * @param <KK> type of the field element
34 *
35 * @author Vincent Cucchietti
36 */
37 public abstract class AbstractFieldOrbitInterpolator<KK extends CalculusFieldElement<KK>>
38 extends AbstractFieldTimeInterpolator<FieldOrbit<KK>, KK> {
39
40 /** Output inertial frame. */
41 private final Frame outputInertialFrame;
42
43 /**
44 * Constructor.
45 *
46 * @param interpolationPoints number of interpolation points
47 * @param extrapolationThreshold extrapolation threshold beyond which the propagation will fail
48 * @param outputInertialFrame output inertial frame
49 */
50 public AbstractFieldOrbitInterpolator(final int interpolationPoints, final double extrapolationThreshold,
51 final Frame outputInertialFrame) {
52 super(interpolationPoints, extrapolationThreshold);
53 checkFrameIsInertial(outputInertialFrame);
54 this.outputInertialFrame = outputInertialFrame;
55 }
56
57 /** {@inheritDoc}. */
58 @Override
59 public FieldOrbit<KK> interpolate(final FieldAbsoluteDate<KK> interpolationDate,
60 final Collection<FieldOrbit<KK>> sample) {
61
62 // Convert to orbit list
63 final List<Orbit> orbits = sample.stream().map(FieldOrbit::toOrbit).collect(Collectors.toList());
64
65 // Check orbits consistency
66 AbstractOrbitInterpolator.checkOrbitsConsistency(orbits);
67
68 return super.interpolate(interpolationDate, sample);
69 }
70
71 /** Get output inertial frame.
72 * @return output inertial frame
73 */
74 public Frame getOutputInertialFrame() {
75 return outputInertialFrame;
76 }
77
78 /**
79 * Check if given frame is pseudo inertial and throw an error otherwise.
80 *
81 * @param frame frame to check
82 *
83 * @throws OrekitIllegalArgumentException if given frame is not pseudo inertial
84 */
85 private void checkFrameIsInertial(final Frame frame) {
86 if (!frame.isPseudoInertial()) {
87 throw new OrekitIllegalArgumentException(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, frame.getName());
88 }
89 }
90 }