AbstractFieldOrbitInterpolator.java

  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. import org.hipparchus.CalculusFieldElement;
  19. import org.orekit.errors.OrekitIllegalArgumentException;
  20. import org.orekit.errors.OrekitMessages;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.time.AbstractFieldTimeInterpolator;
  23. import org.orekit.time.FieldAbsoluteDate;

  24. import java.util.Collection;
  25. import java.util.List;
  26. import java.util.stream.Collectors;

  27. /**
  28.  * Abstract class for orbit interpolator.
  29.  *
  30.  * @param <KK> type of the field element
  31.  *
  32.  * @author Vincent Cucchietti
  33.  */
  34. public abstract class AbstractFieldOrbitInterpolator<KK extends CalculusFieldElement<KK>>
  35.         extends AbstractFieldTimeInterpolator<FieldOrbit<KK>, KK> {

  36.     /** Output inertial frame. */
  37.     private final Frame outputInertialFrame;

  38.     /**
  39.      * Constructor.
  40.      *
  41.      * @param interpolationPoints number of interpolation points
  42.      * @param extrapolationThreshold extrapolation threshold beyond which the propagation will fail
  43.      * @param outputInertialFrame output inertial frame
  44.      */
  45.     public AbstractFieldOrbitInterpolator(final int interpolationPoints, final double extrapolationThreshold,
  46.                                           final Frame outputInertialFrame) {
  47.         super(interpolationPoints, extrapolationThreshold);
  48.         checkFrameIsInertial(outputInertialFrame);
  49.         this.outputInertialFrame = outputInertialFrame;
  50.     }

  51.     /** {@inheritDoc}. */
  52.     @Override
  53.     public FieldOrbit<KK> interpolate(final FieldAbsoluteDate<KK> interpolationDate,
  54.                                       final Collection<FieldOrbit<KK>> sample) {

  55.         // Convert to orbit list
  56.         final List<Orbit> orbits = sample.stream().map(FieldOrbit::toOrbit).collect(Collectors.toList());

  57.         // Check orbits consistency
  58.         AbstractOrbitInterpolator.checkOrbitsConsistency(orbits);

  59.         return super.interpolate(interpolationDate, sample);
  60.     }

  61.     /** Get output inertial frame.
  62.      * @return output inertial frame
  63.      */
  64.     public Frame getOutputInertialFrame() {
  65.         return outputInertialFrame;
  66.     }

  67.     /**
  68.      * Check if given frame is pseudo inertial and throw an error otherwise.
  69.      *
  70.      * @param frame frame to check
  71.      *
  72.      * @throws OrekitIllegalArgumentException if given frame is not pseudo inertial
  73.      */
  74.     private void checkFrameIsInertial(final Frame frame) {
  75.         if (!frame.isPseudoInertial()) {
  76.             throw new OrekitIllegalArgumentException(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, frame.getName());
  77.         }
  78.     }
  79. }