FieldTimeInterpolable.java

  1. /* Copyright 2002-2020 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.time;

  18. import org.hipparchus.RealFieldElement;

  19. import java.util.Collection;
  20. import java.util.stream.Stream;

  21. /** This interface represents objects that can be interpolated in time.
  22.  * @param <T> Type of the object.
  23.  * @param <KK> type of the field elements
  24.  * @author Luc Maisonobe
  25.  */
  26. public interface FieldTimeInterpolable <T extends FieldTimeInterpolable<T, KK>, KK extends RealFieldElement<KK>> {

  27.     /** Get an interpolated instance.
  28.      * <p>
  29.      * Note that the state of the current instance may not be used
  30.      * in the interpolation process, only its type and non interpolable
  31.      * fields are used (for example central attraction coefficient or
  32.      * frame when interpolating orbits). The interpolable fields taken
  33.      * into account are taken only from the states of the sample points.
  34.      * So if the state of the instance must be used, the instance should
  35.      * be included in the sample points.
  36.      * </p>
  37.      * <p>
  38.      * Note that this method is designed for small samples only (say up
  39.      * to about 10-20 points) so it can be implemented using polynomial
  40.      * interpolation (typically Hermite interpolation). Using too much
  41.      * points may induce <a
  42.      * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's
  43.      * phenomenon</a> and numerical problems (including NaN appearing).
  44.      * </p>
  45.      * @param date interpolation date
  46.      * @param sample sample points on which interpolation should be done
  47.      * @return a new instance, interpolated at specified date
  48.      */
  49.     default T interpolate(FieldAbsoluteDate<KK> date, Collection<T> sample) {
  50.         return interpolate(date, sample.stream());
  51.     }

  52.     /** Get an interpolated instance.
  53.      * <p>
  54.      * Note that the state of the current instance may not be used
  55.      * in the interpolation process, only its type and non interpolable
  56.      * fields are used (for example central attraction coefficient or
  57.      * frame when interpolating orbits). The interpolable fields taken
  58.      * into account are taken only from the states of the sample points.
  59.      * So if the state of the instance must be used, the instance should
  60.      * be included in the sample points.
  61.      * </p>
  62.      * <p>
  63.      * Note that this method is designed for small samples only (say up
  64.      * to about 10-20 points) so it can be implemented using polynomial
  65.      * interpolation (typically Hermite interpolation). Using too much
  66.      * points may induce <a
  67.      * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's
  68.      * phenomenon</a> and numerical problems (including NaN appearing).
  69.      * </p>
  70.      * @param date interpolation date
  71.      * @param sample sample points on which interpolation should be done
  72.      * @return a new instance, interpolated at specified date
  73.      */
  74.     T interpolate(FieldAbsoluteDate<KK> date, Stream<T> sample);

  75. }