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.models.earth.tessellation;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.geometry.euclidean.threed.Vector3D;
23 import org.hipparchus.geometry.spherical.twod.S2Point;
24 import org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet;
25 import org.hipparchus.util.FastMath;
26 import org.orekit.bodies.GeodeticPoint;
27
28 /** Class used to orient tiles such that there are no singularities within the zone of interest.
29 * <p>
30 * This class is mainly useful for {@link EllipsoidTessellator#sample(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet,
31 * double, double) sampling} a zone on ground when the grid directions is not really important
32 * and when the zone contains the pole, which is a singular point for both
33 * {@link ConstantAzimuthAiming} and {@link AlongTrackAiming}.
34 * </p>
35 * @see AlongTrackAiming
36 * @see ConstantAzimuthAiming
37 * @author Luc Maisonobe
38 */
39 public class DivertedSingularityAiming implements TileAiming {
40
41 /** Singularity location. */
42 private final Vector3D singularity;
43
44 /** Singularity location. */
45 private final GeodeticPoint singularityGP;
46
47 /** Dipole moment. */
48 private final Vector3D moment;
49
50 /** Simple constructor.
51 * @param forbiddenZone zone out of which singularity should be diverted
52 */
53 public DivertedSingularityAiming(final SphericalPolygonsSet forbiddenZone) {
54 final S2Point outside = forbiddenZone.getEnclosingCap().getCenter().negate();
55 this.singularity = outside.getVector();
56 this.singularityGP = new GeodeticPoint(0.5 * FastMath.PI - outside.getPhi(), outside.getTheta(), 0.0);
57 this.moment = singularity.orthogonal();
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 public List<GeodeticPoint> getSingularPoints() {
63 return Collections.singletonList(singularityGP);
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) {
69
70 // compute the dipole field at point
71 final Vector3D p = new S2Point(gp.getLongitude(), 0.5 * FastMath.PI - gp.getLatitude()).getVector();
72 final Vector3D r = p.subtract(singularity).normalize();
73 final Vector3D field = new Vector3D(3.0 * Vector3D.dotProduct(moment, r), r, -1.0, moment);
74
75 // the aiming direction is the horizontal component of the field
76 final Vector3D horizontal = new Vector3D(1, field, -Vector3D.dotProduct(field, p), p);
77 return horizontal.normalize();
78
79 }
80
81 }