LatitudeExtremumDetector.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.propagation.events;

  18. import org.hipparchus.analysis.differentiation.UnivariateDerivative2;
  19. import org.orekit.bodies.BodyShape;
  20. import org.orekit.bodies.FieldGeodeticPoint;
  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.propagation.events.handlers.EventHandler;
  23. import org.orekit.propagation.events.handlers.StopOnIncreasing;

  24. /** Detector for geographic latitude extremum.
  25.  * <p>This detector identifies when a spacecraft reaches its
  26.  * extremum latitudes with respect to a central body.</p>
  27.  * @author Luc Maisonobe
  28.  * @since 7.1
  29.  */
  30. public class LatitudeExtremumDetector extends AbstractGeodeticExtremumDetector<LatitudeExtremumDetector> {

  31.     /** Build a new detector.
  32.      * <p>The new instance uses default values for maximal checking interval
  33.      * ({@link #DEFAULT_MAX_CHECK}) and convergence threshold ({@link
  34.      * #DEFAULT_THRESHOLD}).</p>
  35.      * @param body body on which the latitude is defined
  36.      */
  37.     public LatitudeExtremumDetector(final BodyShape body) {
  38.         this(DEFAULT_MAX_CHECK, DEFAULT_THRESHOLD, body);
  39.     }

  40.     /** Build a detector.
  41.      * @param maxCheck maximal checking interval (s)
  42.      * @param threshold convergence threshold (s)
  43.      * @param body body on which the latitude is defined
  44.      */
  45.     public LatitudeExtremumDetector(final double maxCheck, final double threshold,
  46.                                     final BodyShape body) {
  47.         this(new EventDetectionSettings(maxCheck, threshold, DEFAULT_MAX_ITER), new StopOnIncreasing(), body);
  48.     }

  49.     /** Protected constructor with full parameters.
  50.      * <p>
  51.      * This constructor is not public as users are expected to use the builder
  52.      * API with the various {@code withXxx()} methods to set up the instance
  53.      * in a readable manner without using a huge amount of parameters.
  54.      * </p>
  55.      * @param detectionSettings event detection settings
  56.      * @param handler event handler to call at event occurrences
  57.      * @param body body on which the latitude is defined
  58.      */
  59.     protected LatitudeExtremumDetector(final EventDetectionSettings detectionSettings, final EventHandler handler,
  60.                                        final BodyShape body) {
  61.         super(detectionSettings, handler, body);
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     protected LatitudeExtremumDetector create(final EventDetectionSettings detectionSettings,
  66.                                               final EventHandler newHandler) {
  67.         return new LatitudeExtremumDetector(detectionSettings, newHandler, getBodyShape());
  68.     }

  69.     /** Compute the value of the detection function.
  70.      * <p>
  71.      * The value is the spacecraft latitude time derivative.
  72.      * </p>
  73.      * @param s the current state information: date, kinematics, attitude
  74.      * @return spacecraft latitude time derivative
  75.      */
  76.     public double g(final SpacecraftState s) {
  77.         // convert state to geodetic coordinates
  78.         final FieldGeodeticPoint<UnivariateDerivative2> gp = transformToFieldGeodeticPoint(s);

  79.         // latitude time derivative
  80.         return gp.getLatitude().getFirstDerivative();

  81.     }

  82. }