GroundFieldOfViewDetector.java

  1. /* Copyright 2002-2016 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.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.propagation.events.handlers.EventHandler;
  23. import org.orekit.propagation.events.handlers.StopOnIncreasing;

  24. /**
  25.  * Finder for satellite entry/exit events with respect to a sensor {@link
  26.  * FieldOfView Field Of View} attached to an arbitrary frame.
  27.  *
  28.  * <p> If you only want to compute access times then you should probably use
  29.  * {@link ElevationDetector}.
  30.  *
  31.  * <p>The default implementation behavior is to {@link org.orekit.propagation.events.handlers.EventHandler.Action#CONTINUE
  32.  * continue} propagation at FOV entry and to {@link org.orekit.propagation.events.handlers.EventHandler.Action#STOP
  33.  * stop} propagation at FOV exit. This can be changed by calling {@link
  34.  * #withHandler(EventHandler)} after construction.</p>
  35.  *
  36.  * @author Luc Maisonobe
  37.  * @author Evan Ward
  38.  * @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
  39.  * @see FieldOfViewDetector
  40.  * @see ElevationDetector
  41.  * @since 7.1
  42.  */
  43. public class GroundFieldOfViewDetector extends AbstractDetector<GroundFieldOfViewDetector> {

  44.     /** Serializable UID. */
  45.     private static final long serialVersionUID = 20160114L;

  46.     /** the reference frame attached to the sensor. */
  47.     private final Frame frame;

  48.     /** Field of view of the sensor. */
  49.     private final FieldOfView fov;

  50.     /**
  51.      * Build a new instance.
  52.      *
  53.      * <p>The maximal interval between distance to FOV boundary checks should be
  54.      * smaller than the half duration of the minimal pass to handle, otherwise
  55.      * some short passes could be missed.</p>
  56.      *
  57.      * @param frame the reference frame attached to the sensor.
  58.      * @param fov   Field Of View of the sensor.
  59.      */
  60.     public GroundFieldOfViewDetector(final Frame frame,
  61.                                      final FieldOfView fov) {
  62.         this(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER,
  63.                 new StopOnIncreasing<GroundFieldOfViewDetector>(),
  64.                 frame, fov);
  65.     }

  66.     /**
  67.      * Private constructor with full parameters.
  68.      *
  69.      * <p> This constructor is private as users are expected to use the builder
  70.      * API with the various {@code withXxx()} methods to set up the instance in
  71.      * a readable manner without using a huge amount of parameters. </p>
  72.      *
  73.      * @param maxCheck  maximum checking interval (s)
  74.      * @param threshold convergence threshold (s)
  75.      * @param maxIter   maximum number of iterations in the event time search
  76.      * @param handler   event handler to call at event occurrences
  77.      * @param frame     the reference frame attached to the sensor.
  78.      * @param fov       Field Of View of the sensor.
  79.      */
  80.     private GroundFieldOfViewDetector(final double maxCheck,
  81.                                       final double threshold,
  82.                                       final int maxIter,
  83.                                       final EventHandler<? super GroundFieldOfViewDetector> handler,
  84.                                       final Frame frame,
  85.                                       final FieldOfView fov) {
  86.         super(maxCheck, threshold, maxIter, handler);
  87.         this.frame = frame;
  88.         this.fov = fov;
  89.     }

  90.     /** {@inheritDoc} */
  91.     @Override
  92.     protected GroundFieldOfViewDetector create(final double newMaxCheck,
  93.                                                final double newThreshold,
  94.                                                final int newMaxIter,
  95.                                                final EventHandler<? super GroundFieldOfViewDetector> newHandler) {
  96.         return new GroundFieldOfViewDetector(newMaxCheck, newThreshold,
  97.                 newMaxIter, newHandler, this.frame, this.fov);
  98.     }

  99.     /**
  100.      * Get the sensor reference frame.
  101.      *
  102.      * @return the reference frame attached to the sensor.
  103.      */
  104.     public Frame getFrame() {
  105.         return this.frame;
  106.     }

  107.     /**
  108.      * Get the Field Of View.
  109.      *
  110.      * @return Field Of View
  111.      */
  112.     public FieldOfView getFieldOfView() {
  113.         return fov;
  114.     }

  115.     /**
  116.      * {@inheritDoc}
  117.      *
  118.      * <p> The g function value is the angular offset between the satellite and
  119.      * the {@link FieldOfView#offsetFromBoundary(Vector3D) Field Of View
  120.      * boundary}. It is negative if the satellite is visible within the Field Of
  121.      * View and positive if it is outside of the Field Of View, including the
  122.      * margin. </p>
  123.      *
  124.      * <p> As per the previous definition, when the satellite enters the Field
  125.      * Of View, a decreasing event is generated, and when the satellite leaves
  126.      * the Field Of View, an increasing event is generated. </p>
  127.      */
  128.     public double g(final SpacecraftState s) throws OrekitException {

  129.         // get line of sight in sensor frame
  130.         final Vector3D los = s.getPVCoordinates(this.frame).getPosition();
  131.         return this.fov.offsetFromBoundary(los);

  132.     }

  133. }