AbstractDetector.java

  1. /* Copyright 2002-2013 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.events;

  18. import org.orekit.errors.OrekitException;
  19. import org.orekit.propagation.SpacecraftState;
  20. import org.orekit.time.AbsoluteDate;

  21. /** Common parts shared by several orbital events finders.
  22.  * @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
  23.  * @author Luc Maisonobe
  24.  */
  25. public abstract class AbstractDetector implements EventDetector {

  26.     /** Default maximum checking interval (s). */
  27.     public static final double DEFAULT_MAXCHECK = 600;

  28.     /** Default convergence threshold (s). */
  29.     public static final double DEFAULT_THRESHOLD = 1.e-6;

  30.     /** Default cmaximum number of iterations in the event time search. */
  31.     public static final int DEFAULT_MAX_ITER = 100;

  32.     /** Serializable UID. */
  33.     private static final long serialVersionUID = 20131202l;

  34.     /** Max check interval. */
  35.     private final double maxCheck;

  36.     /** Convergence threshold. */
  37.     private final double threshold;

  38.     /** Maximum number of iterations in the event time search. */
  39.     private final int maxIter;

  40.     /** Build a new instance.
  41.      * @param maxCheck maximum checking interval (s)
  42.      * @param threshold convergence threshold (s)
  43.      * @deprecated as of 6.1, replaced with {@link #AbstractDetector(double, double, int)}
  44.      */
  45.     @Deprecated
  46.     protected AbstractDetector(final double maxCheck, final double threshold) {
  47.         this(maxCheck, threshold, DEFAULT_MAX_ITER);
  48.     }

  49.     /** Build a new instance.
  50.      * @param maxCheck maximum checking interval (s)
  51.      * @param threshold convergence threshold (s)
  52.      * @param maxIter maximum number of iterations in the event time search
  53.      */
  54.     protected AbstractDetector(final double maxCheck, final double threshold, final int maxIter) {
  55.         this.maxCheck  = maxCheck;
  56.         this.threshold = threshold;
  57.         this.maxIter   = maxIter;
  58.     }

  59.     /** {@inheritDoc} */
  60.     public void init(final SpacecraftState s0, final AbsoluteDate t) {
  61.         // do nothing by default
  62.     }

  63.     /** {@inheritDoc}
  64.      * @deprecated as of 6.1 replaced by {@link
  65.      * org.orekit.propagation.events.handlers.EventHandler#eventOccurred(SpacecraftState,
  66.      * EventDetector, boolean)}
  67.      */
  68.     @Deprecated
  69.     public abstract Action eventOccurred(SpacecraftState s, boolean increasing)
  70.         throws OrekitException;

  71.     /** {@inheritDoc} */
  72.     public abstract double g(SpacecraftState s) throws OrekitException;

  73.     /** {@inheritDoc} */
  74.     public double getMaxCheckInterval() {
  75.         return maxCheck;
  76.     }

  77.     /** {@inheritDoc} */
  78.     public int getMaxIterationCount() {
  79.         return maxIter;
  80.     }

  81.     /** {@inheritDoc} */
  82.     public double getThreshold() {
  83.         return threshold;
  84.     }

  85.     /** {@inheritDoc}
  86.      * @deprecated as of 6.1 replaced by {@link
  87.      * org.orekit.propagation.events.handlers.EventHandler#resetState(EventDetector, SpacecraftState)}
  88.      */
  89.     @Deprecated
  90.     public SpacecraftState resetState(final SpacecraftState oldState)
  91.         throws OrekitException {
  92.         return oldState;
  93.     }

  94. }