1   /* Copyright 2002-2021 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  
19  import java.util.Collection;
20  import java.util.stream.Stream;
21  
22  /** This interface represents objects that can be interpolated in time.
23   * @param <T> Type of the object.
24   * @author Luc Maisonobe
25   */
26  public interface TimeInterpolable<T extends TimeInterpolable<T>> {
27  
28      /** Get an interpolated instance.
29       * <p>
30       * Note that the state of the current instance may not be used
31       * in the interpolation process, only its type and non interpolable
32       * fields are used (for example central attraction coefficient or
33       * frame when interpolating orbits). The interpolable fields taken
34       * into account are taken only from the states of the sample points.
35       * So if the state of the instance must be used, the instance should
36       * be included in the sample points.
37       * </p>
38       * <p>
39       * Note that this method is designed for small samples only (say up
40       * to about 10-20 points) so it can be implemented using polynomial
41       * interpolation (typically Hermite interpolation). Using too much
42       * points may induce <a
43       * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's
44       * phenomenon</a> and numerical problems (including NaN appearing).
45       * </p>
46       * @param date interpolation date
47       * @param sample sample points on which interpolation should be done
48       * @return a new instance, interpolated at specified date
49       */
50      default T interpolate(AbsoluteDate date, Collection<T> sample) {
51          return interpolate(date, sample.stream());
52      }
53  
54      /** Get an interpolated instance.
55       * <p>
56       * Note that the state of the current instance may not be used
57       * in the interpolation process, only its type and non interpolable
58       * fields are used (for example central attraction coefficient or
59       * frame when interpolating orbits). The interpolable fields taken
60       * into account are taken only from the states of the sample points.
61       * So if the state of the instance must be used, the instance should
62       * be included in the sample points.
63       * </p>
64       * <p>
65       * Note that this method is designed for small samples only (say up
66       * to about 10-20 points) so it can be implemented using polynomial
67       * interpolation (typically Hermite interpolation). Using too much
68       * points may induce <a
69       * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's
70       * phenomenon</a> and numerical problems (including NaN appearing).
71       * </p>
72       * @param date interpolation date
73       * @param sample sample points on which interpolation should be done
74       * @return a new instance, interpolated at specified date
75            * @since 9.0
76       */
77      T interpolate(AbsoluteDate date, Stream<T> sample);
78  
79  }