Search in sources :

Example 11 with SphericalPolygonsSet

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

the class SphericalPolygonsSetTransferObject method rebuildZone.

/**
 * Rebuild the zone from saved data.
 * @return rebuilt zone
 */
public SphericalPolygonsSet rebuildZone() {
    // rebuild the tree from the flattened arrays
    BSPTree<Sphere2D> node = new BSPTree<Sphere2D>();
    final int nbNodes = cuts.length / 3 + leafs.length;
    cutIndex = 0;
    flagIndex = 0;
    for (nodeIndex = 0; nodeIndex < nbNodes; ++nodeIndex) {
        if (leafs[flagIndex] == nodeIndex) {
            // this is a leaf node
            node.setAttribute(Boolean.valueOf(flags[flagIndex++]));
            while (node.getParent() != null) {
                final BSPTree<Sphere2D> parent = node.getParent();
                if (node == parent.getMinus()) {
                    node = parent.getPlus();
                    break;
                } else {
                    node = parent;
                }
            }
        } else {
            // this is an internal node
            final double x = cuts[cutIndex++];
            final double y = cuts[cutIndex++];
            final double z = cuts[cutIndex++];
            node.insertCut(new Circle(new Vector3D(x, y, z), tolerance));
            node = node.getMinus();
        }
    }
    return new SphericalPolygonsSet(node, tolerance);
}
Also used : BSPTree(org.hipparchus.geometry.partitioning.BSPTree) Circle(org.hipparchus.geometry.spherical.twod.Circle) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Sphere2D(org.hipparchus.geometry.spherical.twod.Sphere2D) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)

Example 12 with SphericalPolygonsSet

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

the class Mesh method getCoverage.

/**
 * Get the zone covered by the mesh.
 * @return mesh coverage
 */
public SphericalPolygonsSet getCoverage() {
    if (coverage == null) {
        // lazy build of mesh coverage
        final List<Mesh.Node> boundary = getTaxicabBoundary(true);
        final S2Point[] vertices = new S2Point[boundary.size()];
        for (int i = 0; i < vertices.length; ++i) {
            vertices[i] = boundary.get(i).getS2P();
        }
        coverage = new SphericalPolygonsSet(zone.getTolerance(), vertices);
    }
    // as caller may modify the BSP tree, we must provide a copy of our safe instance
    return (SphericalPolygonsSet) coverage.copySelf();
}
Also used : S2Point(org.hipparchus.geometry.spherical.twod.S2Point) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Example 13 with SphericalPolygonsSet

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

the class FootprintOverlapDetectorTest method buildFrance.

private SphericalPolygonsSet buildFrance() {
    final SphericalPolygonsSet continental = buildSimpleZone(new double[][] { { 51.14850, 2.51357 }, { 50.94660, 1.63900 }, { 50.12717, 1.33876 }, { 49.34737, -0.98946 }, { 49.77634, -1.93349 }, { 48.64442, -1.61651 }, { 48.90169, -3.29581 }, { 48.68416, -4.59234 }, { 47.95495, -4.49155 }, { 47.57032, -2.96327 }, { 46.01491, -1.19379 }, { 44.02261, -1.38422 }, { 43.42280, -1.90135 }, { 43.03401, -1.50277 }, { 42.34338, 1.82679 }, { 42.47301, 2.98599 }, { 43.07520, 3.10041 }, { 43.39965, 4.55696 }, { 43.12889, 6.52924 }, { 43.69384, 7.43518 }, { 44.12790, 7.54959 }, { 45.02851, 6.74995 }, { 45.33309, 7.09665 }, { 46.42967, 6.50009 }, { 46.27298, 6.02260 }, { 46.72577, 6.03738 }, { 47.62058, 7.46675 }, { 49.01778, 8.09927 }, { 49.20195, 6.65822 }, { 49.44266, 5.89775 }, { 49.98537, 4.79922 } });
    final SphericalPolygonsSet corsica = buildSimpleZone(new double[][] { { 42.15249, 9.56001 }, { 43.00998, 9.39000 }, { 42.62812, 8.74600 }, { 42.25651, 8.54421 }, { 41.58361, 8.77572 }, { 41.38000, 9.22975 } });
    return (SphericalPolygonsSet) new RegionFactory<Sphere2D>().union(continental, corsica);
}
Also used : RegionFactory(org.hipparchus.geometry.partitioning.RegionFactory) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)

Example 14 with SphericalPolygonsSet

use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet 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 15 with SphericalPolygonsSet

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

the class EllipsoidTessellatorTest method testStairedTruncatedTiles.

@Test
public void testStairedTruncatedTiles() throws OrekitException {
    TileAiming aiming = new ConstantAzimuthAiming(ellipsoid, FastMath.toRadians(170.0));
    EllipsoidTessellator tessellator = new EllipsoidTessellator(ellipsoid, aiming, 16);
    SphericalPolygonsSet small = buildSimpleZone(1.0e-10, new double[][] { { 45.335, 0.457 }, { 45.342, 0.469 }, { 45.371, 0.424 } });
    final double maxWidth = 800.0;
    final double maxLength = 10000.0;
    final List<List<Tile>> tiles = tessellator.tessellate(small, maxWidth, maxLength, 0, 0, false, true);
    Assert.assertEquals(1, tiles.size());
    Assert.assertEquals(4, tiles.get(0).size());
    for (final Tile tile : tiles.get(0)) {
        Vector3D v0 = ellipsoid.transform(tile.getVertices()[0]);
        Vector3D v1 = ellipsoid.transform(tile.getVertices()[1]);
        Vector3D v2 = ellipsoid.transform(tile.getVertices()[2]);
        Vector3D v3 = ellipsoid.transform(tile.getVertices()[3]);
        Assert.assertTrue(Vector3D.distance(v0, v1) < (6.0002 / 16.0) * maxLength);
        Assert.assertTrue(Vector3D.distance(v2, v3) < (6.0002 / 16.0) * maxLength);
        Assert.assertEquals(maxWidth, Vector3D.distance(v1, v2), 1.0e-3);
        Assert.assertEquals(maxWidth, Vector3D.distance(v3, v0), 1.0e-3);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) List(java.util.List) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet) Test(org.junit.Test)

Aggregations

SphericalPolygonsSet (org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)20 List (java.util.List)7 S2Point (org.hipparchus.geometry.spherical.twod.S2Point)7 Test (org.junit.Test)7 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)6 RegionFactory (org.hipparchus.geometry.partitioning.RegionFactory)5 Sphere2D (org.hipparchus.geometry.spherical.twod.Sphere2D)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)5 ArrayList (java.util.ArrayList)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 IdentityHashMap (java.util.IdentityHashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)1 BSPTree (org.hipparchus.geometry.partitioning.BSPTree)1 Circle (org.hipparchus.geometry.spherical.twod.Circle)1 Edge (org.hipparchus.geometry.spherical.twod.Edge)1