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.bodies.OneAxisEllipsoid;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.propagation.events.handlers.EventHandler;
  24. import org.orekit.propagation.events.handlers.StopOnIncreasing;

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

  32.     /** Body on which the latitude is defined. */
  33.     private OneAxisEllipsoid body;

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

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

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

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     protected LatitudeExtremumDetector create(final EventDetectionSettings detectionSettings,
  70.                                               final EventHandler newHandler) {
  71.         return new LatitudeExtremumDetector(detectionSettings, newHandler, body);
  72.     }

  73.     /** Get the body on which the geographic zone is defined.
  74.      * @return body on which the geographic zone is defined
  75.      */
  76.     public BodyShape getBody() {
  77.         return body;
  78.     }

  79.     /** Compute the value of the detection function.
  80.      * <p>
  81.      * The value is the spacecraft latitude time derivative.
  82.      * </p>
  83.      * @param s the current state information: date, kinematics, attitude
  84.      * @return spacecraft latitude time derivative
  85.      */
  86.     public double g(final SpacecraftState s) {

  87.         // convert state to geodetic coordinates
  88.         final FieldGeodeticPoint<UnivariateDerivative2> gp =
  89.                         body.transform(s.getPVCoordinates(), s.getFrame(), s.getDate());

  90.         // latitude time derivative
  91.         return gp.getLatitude().getFirstDerivative();

  92.     }

  93. }