1   /* Copyright 2002-2025 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.ssa.metrics;
18  
19  import org.hipparchus.util.MathUtils;
20  import org.orekit.ssa.collision.shorttermencounter.probability.twod.Alfriend1999Max;
21  import org.orekit.ssa.collision.shorttermencounter.probability.twod.Laas2015;
22  
23  /**
24   * Container for values relative to the probability of collision :
25   * <ul>
26   *     <li>Value of the probability of collision.</li>
27   *     <li>Name of the method with which it was computed.</li>
28   *     <li>Upper and lower limit of the value if the method provides them (such as {@link Laas2015} for example).</li>
29   *     <li>Flag defining if the probability was maximized in any way (such as {@link Alfriend1999Max} for example).</li>
30   * </ul>
31   *
32   * @author Vincent Cucchietti
33   * @since 12.0
34   */
35  public class ProbabilityOfCollision {
36  
37      /** Value of the probability of collision. */
38      private final double value;
39  
40      /**
41       * Lower limit of the probability of collision.
42       * <p>
43       * 0 by default.
44       */
45      private final double lowerLimit;
46  
47      /**
48       * Upper limit of the probability of collision.
49       * <p>
50       * 0 by default.
51       */
52      private final double upperLimit;
53  
54      /** Name of the probability computing method with which this probability was calculated. */
55      private final String probabilityOfCollisionMethodName;
56  
57      /**
58       * Defines if this probability of collision can be considered a maximum probability of collision.
59       * <p>
60       * It depends on what method was used to compute this probability.
61       * <p>
62       * False by default.
63       */
64      private final boolean isMaxProbability;
65  
66      /**
67       * Constructor with default values of 0 for the upper/lower limits and default false flag for maximum probability.
68       *
69       * @param value value of the probability of collision
70       * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
71       * computed
72       */
73      public ProbabilityOfCollision(final double value, final String probabilityOfCollisionMethodName) {
74          this(value, 0., 0., probabilityOfCollisionMethodName, false);
75      }
76  
77      /**
78       * Constructor with default values of 0 for the upper and lower limits.
79       *
80       * @param value value of the probability of collision
81       * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
82       * computed
83       * @param isMaxProbability flag defining if it has been computed using a maximum probability of collision method
84       */
85      public ProbabilityOfCollision(final double value, final String probabilityOfCollisionMethodName,
86                                    final boolean isMaxProbability) {
87          this(value, 0., 0., probabilityOfCollisionMethodName, isMaxProbability);
88      }
89  
90      /**
91       * Constructor.
92       *
93       * @param value value of the probability of collision
94       * @param lowerLimit lower limit of the probability of collision
95       * @param upperLimit upper limit of the probability of collision
96       * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
97       * computed
98       * @param isMaxProbability flag indicating if this method computes a maximum probability of collision
99       */
100     public ProbabilityOfCollision(final double value, final double lowerLimit, final double upperLimit,
101                                   final String probabilityOfCollisionMethodName, final boolean isMaxProbability) {
102 
103         // Check that inputs are valid
104         MathUtils.checkRangeInclusive(value, 0, 1);
105         MathUtils.checkRangeInclusive(lowerLimit, 0, 1);
106         MathUtils.checkRangeInclusive(upperLimit, 0, 1);
107 
108         // initialization
109         this.value                            = value;
110         this.lowerLimit                       = lowerLimit;
111         this.upperLimit                       = upperLimit;
112         this.probabilityOfCollisionMethodName = probabilityOfCollisionMethodName;
113         this.isMaxProbability                 = isMaxProbability;
114     }
115 
116     /** Get value of the probability of collision.
117      * @return value of the probability of collision
118      */
119     public double getValue() {
120         return value;
121     }
122 
123     /** Get lower limit of the probability of collision value.
124      * @return lower limit of the probability of collision value, 0 by default
125      */
126     public double getLowerLimit() {
127         return lowerLimit;
128     }
129 
130     /** Get upper limit of the probability of collision value.
131      * @return upper limit of the probability of collision value, 0 by default
132      */
133     public double getUpperLimit() {
134         return upperLimit;
135     }
136 
137     /** Get name of the probability computing method with which this probability was computed.
138      * @return name of the probability computing method with which this probability was computed
139      */
140     public String getProbabilityOfCollisionMethodName() {
141         return probabilityOfCollisionMethodName;
142     }
143 
144     /** Get flag that defines if this probability of collision can be considered a maximum probability of collision.
145      * @return flag that defines if this probability of collision can be considered a maximum probability of collision
146      */
147     public boolean isMaxProbability() {
148         return isMaxProbability;
149     }
150 
151 }