Search in sources :

Example 11 with S2Point

use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.

the class InsideFinder method visitLeafNode.

/**
 * {@inheritDoc}
 */
@Override
public void visitLeafNode(final BSPTree<Sphere2D> node) {
    // we have already found a good point
    if (insidePointFirstChoice != null) {
        return;
    }
    if ((Boolean) node.getAttribute()) {
        // transform this inside leaf cell into a simple convex polygon
        final SphericalPolygonsSet convex = new SphericalPolygonsSet(node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null), zone.getTolerance());
        // extract the start of the single loop boundary of the convex cell
        final List<Vertex> boundary = convex.getBoundaryLoops();
        final Vertex start = boundary.get(0);
        int n = 0;
        Vector3D sumB = Vector3D.ZERO;
        for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
            sumB = new Vector3D(1, sumB, e.getLength(), e.getCircle().getPole());
            n++;
        }
        final S2Point candidate = new S2Point(sumB);
        // and checkPoint selects another (very close) tree leaf node
        if (zone.checkPoint(candidate) == Location.INSIDE) {
            insidePointFirstChoice = candidate;
        } else {
            insidePointSecondChoice = candidate;
        }
    }
}
Also used : Vertex(org.hipparchus.geometry.spherical.twod.Vertex) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet) Edge(org.hipparchus.geometry.spherical.twod.Edge) S2Point(org.hipparchus.geometry.spherical.twod.S2Point)

Example 12 with S2Point

use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.

the class GeographicZoneDetector method g.

/**
 * Compute the value of the detection function.
 * <p>
 * The value is the signed distance to boundary, minus the margin. It is
 * positive if the spacecraft is outside of the zone and negative if it is inside.
 * </p>
 * @param s the current state information: date, kinematics, attitude
 * @return signed distance to boundary minus the margin
 * @exception OrekitException if some specific error occurs
 */
public double g(final SpacecraftState s) throws OrekitException {
    // convert state to geodetic coordinates
    final GeodeticPoint gp = body.transform(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate());
    // map the point to a sphere (geodetic coordinates have already taken care of ellipsoid flatness)
    final S2Point s2p = new S2Point(gp.getLongitude(), 0.5 * FastMath.PI - gp.getLatitude());
    // for faster computation, we start using only the surrounding cap, to filter out
    // far away points (which correspond to most of the points if the zone is small)
    final double crudeDistance = cap.getCenter().distance(s2p) - cap.getRadius();
    if (crudeDistance - margin > FastMath.max(FastMath.abs(margin), 0.01)) {
        // use the crude distance to compute the (positive) return value
        return crudeDistance - margin;
    }
    // project the point to the closest zone boundary
    return zone.projectToBoundary(s2p).getOffset() - margin;
}
Also used : S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Example 13 with S2Point

use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.

the class DOPComputation method computeSPS.

/**
 * Computes a spherical polygons set from a geographic zone.
 *
 * @param zone the geographic zone
 * @return the spherical polygons set
 */
private static SphericalPolygonsSet computeSPS(final List<GeodeticPoint> zone) {
    // Convert the area into a SphericalPolygonsSet
    final S2Point[] vertices = new S2Point[zone.size()];
    int i = 0;
    for (GeodeticPoint point : zone) {
        final double theta = point.getLongitude();
        final double phi = 0.5 * FastMath.PI - point.getLatitude();
        vertices[i++] = new S2Point(theta, phi);
    }
    return new SphericalPolygonsSet(1.0e-10, vertices);
}
Also used : S2Point(org.hipparchus.geometry.spherical.twod.S2Point) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet) GeodeticPoint(org.orekit.bodies.GeodeticPoint) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Aggregations

S2Point (org.hipparchus.geometry.spherical.twod.S2Point)13 GeodeticPoint (org.orekit.bodies.GeodeticPoint)8 SphericalPolygonsSet (org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)7 ArrayList (java.util.ArrayList)5 List (java.util.List)4 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 Edge (org.hipparchus.geometry.spherical.twod.Edge)3 Sphere2D (org.hipparchus.geometry.spherical.twod.Sphere2D)3 Vertex (org.hipparchus.geometry.spherical.twod.Vertex)3 IdentityHashMap (java.util.IdentityHashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 RegionFactory (org.hipparchus.geometry.partitioning.RegionFactory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Line (org.hipparchus.geometry.euclidean.threed.Line)1 Test (org.junit.Test)1 OrekitException (org.orekit.errors.OrekitException)1