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