1   /* Copyright 2020-2025 Exotrail
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.propagation.conversion.averaging.converters;
18  
19  import org.orekit.propagation.conversion.averaging.AveragedOrbitalState;
20  
21  /**
22   * Abstract class for osculating-to-averaged converters based on a fixed-point algorithm.
23   *
24   * @author Romain Serra
25   * @since 12.1
26   * @see OsculatingToAveragedConverter
27   * @param <T> type of averaged orbital state
28   */
29  public abstract class FixedPointOsculatingToAveragedConverter<T extends AveragedOrbitalState>
30          implements OsculatingToAveragedConverter<T> {
31  
32      /** Default convergence threshold. */
33      public static final double DEFAULT_EPSILON = 1e-12;
34      /** Default maximum number of iterations. */
35      public static final int DEFAULT_MAX_ITERATIONS = 100;
36  
37      /** Convergence threshold. */
38      private double epsilon;
39      /** Maximum number of iterations. */
40      private int maxIterations;
41  
42      /**
43       * Protected constructor.
44       * @param epsilon tolerance for convergence
45       * @param maxIterations maximum number of iterations
46       */
47      protected FixedPointOsculatingToAveragedConverter(final double epsilon,
48                                                        final int maxIterations) {
49          this.epsilon = epsilon;
50          this.maxIterations = maxIterations;
51      }
52  
53      /**
54       * Getter for the maximum number of iterations.
55       * @return maximum number of iterations
56       */
57      public int getMaxIterations() {
58          return maxIterations;
59      }
60  
61      /**
62       * Getter for the convergence threshold.
63       * @return convergence threshold
64       */
65      public double getEpsilon() {
66          return epsilon;
67      }
68  
69      /**
70       * Setter for epsilon.
71       * @param epsilon convergence threshold.
72       */
73      public void setEpsilon(final double epsilon) {
74          this.epsilon = epsilon;
75      }
76  
77      /**
78       * Setter for maximum number of iterations.
79       * @param maxIterations maximum iterations
80       */
81      public void setMaxIterations(final int maxIterations) {
82          this.maxIterations = maxIterations;
83      }
84  }