List of usage examples for org.apache.commons.math3.geometry.spherical.twod SphericalPolygonsSet SphericalPolygonsSet
public SphericalPolygonsSet(final Vector3D center, final Vector3D meridian, final double outsideRadius, final int n, final double tolerance)
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Extract tiles from a mesh. * @param mesh mesh from which tiles should be extracted * @param zone zone covered by the mesh// ww w. j a v a 2 s.c o m * @param lengthOverlap overlap between adjacent tiles * @param widthOverlap overlap between adjacent tiles * @param truncateLastWidth true if we can reduce last tile width * @param truncateLastLength true if we can reduce last tile length * @return extracted tiles * @exception OrekitException if tile direction cannot be computed */ private List<Tile> extractTiles(final Mesh mesh, final SphericalPolygonsSet zone, final double lengthOverlap, final double widthOverlap, final boolean truncateLastWidth, final boolean truncateLastLength) throws OrekitException { final List<Tile> tiles = new ArrayList<Tile>(); final List<RangePair> rangePairs = new ArrayList<RangePair>(); final int minAcross = mesh.getMinAcrossIndex(); final int maxAcross = mesh.getMaxAcrossIndex(); for (Range acrossPair : nodesIndices(minAcross, maxAcross, truncateLastWidth)) { int minAlong = mesh.getMaxAlongIndex() + 1; int maxAlong = mesh.getMinAlongIndex() - 1; for (int c = acrossPair.lower; c <= acrossPair.upper; ++c) { minAlong = FastMath.min(minAlong, mesh.getMinAlongIndex(c)); maxAlong = FastMath.max(maxAlong, mesh.getMaxAlongIndex(c)); } for (Range alongPair : nodesIndices(minAlong, maxAlong, truncateLastLength)) { // get the base vertex nodes final Mesh.Node node0 = mesh.addNode(alongPair.lower, acrossPair.lower); final Mesh.Node node1 = mesh.addNode(alongPair.upper, acrossPair.lower); final Mesh.Node node2 = mesh.addNode(alongPair.upper, acrossPair.upper); final Mesh.Node node3 = mesh.addNode(alongPair.lower, acrossPair.upper); // apply tile overlap final S2Point s2p0 = node0.move(new Vector3D(-0.5 * lengthOverlap, node0.getAlong(), -0.5 * widthOverlap, node0.getAcross())); final S2Point s2p1 = node1.move(new Vector3D(+0.5 * lengthOverlap, node1.getAlong(), -0.5 * widthOverlap, node1.getAcross())); final S2Point s2p2 = node2.move(new Vector3D(+0.5 * lengthOverlap, node2.getAlong(), +0.5 * widthOverlap, node2.getAcross())); final S2Point s2p3 = node3.move(new Vector3D(-0.5 * lengthOverlap, node2.getAlong(), +0.5 * widthOverlap, node2.getAcross())); // create a quadrilateral region corresponding to the candidate tile final SphericalPolygonsSet quadrilateral = new SphericalPolygonsSet(zone.getTolerance(), s2p0, s2p1, s2p2, s2p3); if (!new RegionFactory<Sphere2D>().intersection(zone.copySelf(), quadrilateral).isEmpty()) { // the tile does cover part of the zone, it contributes to the tessellation tiles.add(new Tile(toGeodetic(s2p0), toGeodetic(s2p1), toGeodetic(s2p2), toGeodetic(s2p3))); rangePairs.add(new RangePair(acrossPair, alongPair)); } } } // ensure the taxicab boundary follows the built tile sides // this is done outside of the previous loop because in order // to avoid one tile changing the min/max indices of the // neighboring tile as they share some nodes that will be enabled here for (final RangePair rangePair : rangePairs) { for (int c = rangePair.across.lower; c < rangePair.across.upper; ++c) { mesh.addNode(rangePair.along.lower, c + 1).setEnabled(); mesh.addNode(rangePair.along.upper, c).setEnabled(); } for (int l = rangePair.along.lower; l < rangePair.along.upper; ++l) { mesh.addNode(l, rangePair.across.lower).setEnabled(); mesh.addNode(l + 1, rangePair.across.upper).setEnabled(); } } return tiles; }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellatorTest.java
private void checkTilesDontOverlap(final List<List<Tile>> tiles) { for (final List<Tile> list : tiles) { for (final Tile tile : list) { final SphericalPolygonsSet quadrilateral = new SphericalPolygonsSet(1.0e-10, toS2Point(tile.getVertices()[0]), toS2Point(tile.getVertices()[1]), toS2Point(tile.getVertices()[2]), toS2Point(tile.getVertices()[3])); for (final List<Tile> otherList : tiles) { for (final Tile otherTile : otherList) { if (otherTile != tile) { for (final GeodeticPoint vertex : otherTile.getVertices()) { Assert.assertEquals("tiles overlap at: " + vertex, Location.OUTSIDE, quadrilateral.checkPoint(toS2Point(vertex))); }/* w w w . jav a 2 s.co m*/ } } } } } }