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  
19  import org.orekit.propagation.SpacecraftState;
20  import org.orekit.propagation.events.handlers.EventHandler;
21  import org.orekit.propagation.events.handlers.StopOnIncreasing;
22  
23  /** Detector for XZ Plane crossing.
24   * @author Vincent Mouraux
25   * @since 10.2
26   */
27  public class HaloXZPlaneCrossingDetector extends AbstractDetector<HaloXZPlaneCrossingDetector> {
28  
29      /**
30       * Simple Constructor.
31       * @param maxCheck maximum checking interval (s)
32       * @param threshold convergence threshold (s)
33       */
34      public HaloXZPlaneCrossingDetector(final double maxCheck, final double threshold) {
35          this(new EventDetectionSettings(maxCheck, threshold, DEFAULT_MAX_ITER), new StopOnIncreasing());
36      }
37  
38      /**
39       * Protected constructor with full parameters.
40       * <p>
41       * This constructor is not public as users are expected to use the builder API
42       * with the various {@code withXxx()} methods to set up the instance in a
43       * readable manner without using a huge amount of parameters.
44       * </p>
45       * @param detectionSettings event detection settings
46       * @param handler event handler to call at event occurrences
47       * @since 13.0
48       */
49      protected HaloXZPlaneCrossingDetector(final EventDetectionSettings detectionSettings,
50                                            final EventHandler handler) {
51          super(detectionSettings, handler);
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      protected HaloXZPlaneCrossingDetector create(final EventDetectionSettings detectionSettings,
57                                                   final EventHandler newHandler) {
58          return new HaloXZPlaneCrossingDetector(detectionSettings, newHandler);
59      }
60  
61      /** Compute the value of the detection function.
62       * @param s the current state information: date, kinematics, attitude
63       * @return Position on Y axis
64       */
65      public double g(final SpacecraftState s) {
66          return s.getPosition().getY();
67      }
68  
69  }