TimeInterpolable.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 java.util.Collection;
  19. import java.util.stream.Stream;

  20. /** This interface represents objects that can be interpolated in time.
  21.  * @param <T> Type of the object.
  22.  * @author Luc Maisonobe
  23.  */
  24. public interface TimeInterpolable<T extends TimeInterpolable<T>> {

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

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

  74. }