List of usage examples for org.apache.commons.math3.geometry.spherical.twod SphericalPolygonsSet SphericalPolygonsSet
public SphericalPolygonsSet(final double hyperplaneThickness, final S2Point... vertices)
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Build a simple zone (connected zone without holes). * <p>/*from w ww . jav a 2 s. c o m*/ * In order to build more complex zones (not connected or with * holes), the user should directly call Apache Commons * Math {@link SphericalPolygonsSet} constructors and * {@link RegionFactory region factory} if set operations * are needed (union, intersection, difference ...). * </p> * <p> * Take care that the vertices boundary points must be given <em>counterclockwise</em>. * Using the wrong order defines the complementary of the real zone, * and will often result in tessellation failure as the zone is too * wide. * </p> * @param tolerance angular separation below which points are considered * equal (typically 1.0e-10) * @param points vertices of the boundary, in <em>counterclockwise</em> * order, each point being a two-elements arrays with latitude at index 0 * and longitude at index 1 * @return a zone defined on the unit 2-sphere */ public static SphericalPolygonsSet buildSimpleZone(final double tolerance, final double[]... points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(points[i][1], 0.5 * FastMath.PI - points[i][0]); } return new SphericalPolygonsSet(tolerance, vertices); }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Build a simple zone (connected zone without holes). * <p>//from w w w . ja va 2 s .com * In order to build more complex zones (not connected or with * holes), the user should directly call Apache Commons * Math {@link SphericalPolygonsSet} constructors and * {@link RegionFactory region factory} if set operations * are needed (union, intersection, difference ...). * </p> * <p> * Take care that the vertices boundary points must be given <em>counterclockwise</em>. * Using the wrong order defines the complementary of the real zone, * and will often result in tessellation failure as the zone is too * wide. * </p> * @param tolerance angular separation below which points are considered * equal (typically 1.0e-10) * @param points vertices of the boundary, in <em>counterclockwise</em> * order * @return a zone defined on the unit 2-sphere */ public static SphericalPolygonsSet buildSimpleZone(final double tolerance, final GeodeticPoint... points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(points[i].getLongitude(), 0.5 * FastMath.PI - points[i].getLatitude()); } return new SphericalPolygonsSet(tolerance, vertices); }
From source file:org.orekit.models.earth.tessellation.InsideFinder.java
/** {@inheritDoc} */ @Override/*from w w w.j a v a 2 s.com*/ 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); // check the candidate point is really considered inside // it may appear outside if the current leaf cell is very thin // and checkPoint selects another (very close) tree leaf node if (zone.checkPoint(candidate) == Location.INSIDE) { insidePointFirstChoice = candidate; } else { insidePointSecondChoice = candidate; } } }
From source file:org.orekit.models.earth.tessellation.Mesh.java
/** Get the zone covered by the mesh. * @return mesh coverage/*w ww.j a v a2 s .co m*/ */ 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(); }
From source file:org.orekit.propagation.events.GeographicZoneDetectorTest.java
private SphericalPolygonsSet buildSimpleZone(double[][] points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(FastMath.toRadians(points[i][1]), // points[i][1] is longitude FastMath.toRadians(90.0 - points[i][0])); // points[i][0] is latitude }//from w w w . ja v a 2s . com return new SphericalPolygonsSet(1.0e-10, vertices); }