DivertedSingularityAiming.java

  1. /* Copyright 2002-2024 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.models.earth.tessellation;

  18. import java.util.Collections;
  19. import java.util.List;

  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.hipparchus.geometry.spherical.twod.S2Point;
  22. import org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.bodies.GeodeticPoint;

  25. /** Class used to orient tiles such that there are no singularities within the zone of interest.
  26.  * <p>
  27.  * This class is mainly useful for {@link EllipsoidTessellator#sample(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet,
  28.  * double, double) sampling} a zone on ground when the grid directions is not really important
  29.  * and when the zone contains the pole, which is a singular point for both
  30.  * {@link ConstantAzimuthAiming} and {@link AlongTrackAiming}.
  31.  * </p>
  32.  * @see AlongTrackAiming
  33.  * @see ConstantAzimuthAiming
  34.  * @author Luc Maisonobe
  35.  */
  36. public class DivertedSingularityAiming implements TileAiming {

  37.     /** Singularity location. */
  38.     private final Vector3D singularity;

  39.     /** Singularity location. */
  40.     private final GeodeticPoint singularityGP;

  41.     /** Dipole moment. */
  42.     private final Vector3D moment;

  43.     /** Simple constructor.
  44.      * @param forbiddenZone zone out of which singularity should be diverted
  45.      */
  46.     public DivertedSingularityAiming(final SphericalPolygonsSet forbiddenZone) {
  47.         final S2Point outside = forbiddenZone.getEnclosingCap().getCenter().negate();
  48.         this.singularity      = outside.getVector();
  49.         this.singularityGP    = new GeodeticPoint(0.5 * FastMath.PI - outside.getPhi(), outside.getTheta(), 0.0);
  50.         this.moment           = singularity.orthogonal();
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public List<GeodeticPoint> getSingularPoints() {
  55.         return Collections.singletonList(singularityGP);
  56.     }

  57.     /** {@inheritDoc} */
  58.     @Override
  59.     public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) {

  60.         // compute the dipole field at point
  61.         final Vector3D p     = new S2Point(gp.getLongitude(), 0.5 * FastMath.PI - gp.getLatitude()).getVector();
  62.         final Vector3D r     = p.subtract(singularity).normalize();
  63.         final Vector3D field = new Vector3D(3.0 * Vector3D.dotProduct(moment, r), r, -1.0, moment);

  64.         // the aiming direction is the horizontal component of the field
  65.         final Vector3D horizontal = new Vector3D(1, field, -Vector3D.dotProduct(field, p), p);
  66.         return horizontal.normalize();

  67.     }

  68. }