FieldProbabilityOfCollision.java

  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. import org.hipparchus.CalculusFieldElement;
  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.  * Container for values relative to the probability of collision :
  24.  * <ul>
  25.  *     <li>Value of the probability of collision.</li>
  26.  *     <li>Name of the method with which it was computed.</li>
  27.  *     <li>Upper and lower limit of the value if the method provides them (such as {@link Laas2015} for example).</li>
  28.  *     <li>Flag defining if the probability was maximized in any way (such as {@link Alfriend1999Max} for example).</li>
  29.  * </ul>
  30.  *
  31.  * @author Vincent Cucchietti
  32.  * @since 12.0
  33.  * @param <T> type of the field elements
  34.  */
  35. public class FieldProbabilityOfCollision<T extends CalculusFieldElement<T>> {

  36.     /** Value of the probability of collision. */
  37.     private final T value;

  38.     /**
  39.      * Lower limit of the probability of collision.
  40.      * <p>
  41.      * 0 by default.
  42.      */
  43.     private final T lowerLimit;

  44.     /**
  45.      * Upper limit of the probability of collision.
  46.      * <p>
  47.      * 0 by default.
  48.      */
  49.     private final T upperLimit;

  50.     /** Name of the probability computing method with which this probability was calculated. */
  51.     private final String probabilityOfCollisionMethodName;

  52.     /**
  53.      * Defines if this probability of collision can be considered a maximum probability of collision.
  54.      * <p>
  55.      * It depends on what method was used to compute this probability.
  56.      * <p>
  57.      * False by default.
  58.      */
  59.     private final boolean isMaxProbability;

  60.     /**
  61.      * Constructor with default values of 0 for the upper/lower limits and default false flag for maximum probability.
  62.      *
  63.      * @param value value of the probability of collision
  64.      * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
  65.      * computed
  66.      */
  67.     public FieldProbabilityOfCollision(final T value, final String probabilityOfCollisionMethodName) {
  68.         this(value, probabilityOfCollisionMethodName, false);
  69.     }

  70.     /**
  71.      * Constructor with default values of 0 for the upper and lower limits.
  72.      *
  73.      * @param value value of the probability of collision
  74.      * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
  75.      * computed
  76.      * @param isMaxProbability flag defining if it has been computed using a maximum probability of collision method
  77.      */
  78.     public FieldProbabilityOfCollision(final T value, final String probabilityOfCollisionMethodName,
  79.                                        final boolean isMaxProbability) {
  80.         this(value, value.getField().getZero(), value.getField().getZero(), probabilityOfCollisionMethodName,
  81.              isMaxProbability);
  82.     }

  83.     /**
  84.      * Constructor.
  85.      *
  86.      * @param value value of the probability of collision
  87.      * @param lowerLimit lower limit of the probability of collision
  88.      * @param upperLimit upper limit of the probability of collision
  89.      * @param probabilityOfCollisionMethodName name of the probability computing method with which this probability was
  90.      * computed
  91.      * @param isMaxProbability flag indicating if this method computes a maximum probability of collision
  92.      */
  93.     public FieldProbabilityOfCollision(final T value, final T lowerLimit, final T upperLimit,
  94.                                        final String probabilityOfCollisionMethodName, final boolean isMaxProbability) {

  95.         // Check that inputs are valid
  96.         MathUtils.checkRangeInclusive(value.getReal(), 0, 1);
  97.         MathUtils.checkRangeInclusive(lowerLimit.getReal(), 0, 1);
  98.         MathUtils.checkRangeInclusive(upperLimit.getReal(), 0, 1);

  99.         // Initialization
  100.         this.value                            = value;
  101.         this.lowerLimit                       = lowerLimit;
  102.         this.upperLimit                       = upperLimit;
  103.         this.probabilityOfCollisionMethodName = probabilityOfCollisionMethodName;
  104.         this.isMaxProbability                 = isMaxProbability;
  105.     }

  106.     /** Get value of the probability of collision.
  107.      * @return value of the probability of collision
  108.      */
  109.     public T getValue() {
  110.         return value;
  111.     }

  112.     /** Get lower limit of the probability of collision value.
  113.      * @return lower limit of the probability of collision value, 0 by default
  114.      */
  115.     public T getLowerLimit() {
  116.         return lowerLimit;
  117.     }

  118.     /** Get upper limit of the probability of collision value.
  119.      * @return upper limit of the probability of collision value, 0 by default
  120.      */
  121.     public T getUpperLimit() {
  122.         return upperLimit;
  123.     }

  124.     /** Get name of the probability computing method with which this probability was computed.
  125.      * @return name of the probability computing method with which this probability was computed
  126.      */
  127.     public String getProbabilityOfCollisionMethodName() {
  128.         return probabilityOfCollisionMethodName;
  129.     }

  130.     /** Get flag that defines if this probability of collision can be considered a maximum probability of collision.
  131.      * @return flag that defines if this probability of collision can be considered a maximum probability of collision
  132.      */
  133.     public boolean isMaxProbability() {
  134.         return isMaxProbability;
  135.     }

  136. }