public class SphericalPolygonsSet extends AbstractRegion<Sphere2D,Sphere1D>
Region.Location
Constructor and Description 

SphericalPolygonsSet(BSPTree<Sphere2D> tree,
double tolerance)
Build a polygons set from a BSP tree.

SphericalPolygonsSet(Collection<SubHyperplane<Sphere2D>> boundary,
double tolerance)
Build a polygons set from a Boundary REPresentation (Brep).

SphericalPolygonsSet(double tolerance)
Build a polygons set representing the whole real 2sphere.

SphericalPolygonsSet(double hyperplaneThickness,
S2Point... vertices)
Build a polygon from a simple list of vertices.

SphericalPolygonsSet(Vector3D pole,
double tolerance)
Build a polygons set representing a hemisphere.

SphericalPolygonsSet(Vector3D center,
Vector3D meridian,
double outsideRadius,
int n,
double tolerance)
Build a polygons set representing a regular polygon.

Modifier and Type  Method and Description 

SphericalPolygonsSet 
buildNew(BSPTree<Sphere2D> tree)
Build a region using the instance as a prototype.

protected void 
computeGeometricalProperties()
Compute some geometrical properties.

List<Vertex> 
getBoundaryLoops()
Get the boundary loops of the polygon.

EnclosingBall<Sphere2D,S2Point> 
getEnclosingCap()
Get a spherical cap enclosing the polygon.

applyTransform, checkPoint, checkPoint, checkPoint, checkPoint, contains, copySelf, getBarycenter, getBoundarySize, getSize, getTolerance, getTree, intersection, isEmpty, isEmpty, isFull, isFull, projectToBoundary, setBarycenter, setBarycenter, setSize
public SphericalPolygonsSet(double tolerance) throws MathIllegalArgumentException
tolerance
 below which points are consider to be identicalMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
public SphericalPolygonsSet(Vector3D pole, double tolerance) throws MathIllegalArgumentException
pole
 pole of the hemisphere (the pole is in the inside half)tolerance
 below which points are consider to be identicalMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
public SphericalPolygonsSet(Vector3D center, Vector3D meridian, double outsideRadius, int n, double tolerance) throws MathIllegalArgumentException
center
 center of the polygon (the center is in the inside half)meridian
 point defining the reference meridian for first polygon vertexoutsideRadius
 distance of the vertices to the centern
 number of sides of the polygontolerance
 below which points are consider to be identicalMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
public SphericalPolygonsSet(BSPTree<Sphere2D> tree, double tolerance) throws MathIllegalArgumentException
The leaf nodes of the BSP tree must have a
Boolean
attribute representing the inside status of
the corresponding cell (true for inside cells, false for outside
cells). In order to avoid building too many small objects, it is
recommended to use the predefined constants
Boolean.TRUE
and Boolean.FALSE
tree
 inside/outside BSP tree representing the regiontolerance
 below which points are consider to be identicalMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
public SphericalPolygonsSet(Collection<SubHyperplane<Sphere2D>> boundary, double tolerance) throws MathIllegalArgumentException
The boundary is provided as a collection of subhyperplanes
. Each subhyperplane has the
interior part of the region on its minus side and the exterior on
its plus side.
The boundary elements can be in any order, and can form
several nonconnected sets (like for example polygons with holes
or a set of disjoint polygons considered as a whole). In
fact, the elements do not even need to be connected together
(their topological connections are not used here). However, if the
boundary does not really separate an inside open from an outside
open (open having here its topological meaning), then subsequent
calls to the checkPoint
method will not be meaningful anymore.
If the boundary is empty, the region will represent the whole space.
boundary
 collection of boundary elements, as a
collection of SubHyperplane
objectstolerance
 below which points are consider to be identicalMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
public SphericalPolygonsSet(double hyperplaneThickness, S2Point... vertices) throws MathIllegalArgumentException
The boundary is provided as a list of points considering to represent the vertices of a simple loop. The interior part of the region is on the left side of this path and the exterior is on its right side.
This constructor does not handle polygons with a boundary forming several disconnected paths (such as polygons with holes).
For cases where this simple constructor applies, it is expected to
be numerically more robust than the general constructor
using subhyperplanes
.
If the list is empty, the region will represent the whole space.
This constructor assumes that edges between vertices
, including the edge
between the last and the first vertex, are shorter than pi. If edges longer than pi
are used it may produce unintuitive results, such as reversing the direction of the
edge. This implies using a vertices
array of length 1 or 2 in this
constructor produces an illdefined region. Use one of the other constructors or
RegionFactory
instead.
The list of vertices
is reduced by selecting a subset of vertices
before creating the boundary set. Every point in vertices
will be on the
boundary
of the constructed polygon set, but not
necessarily the centerline of the boundary.
Polygons with thin pikes or dents are inherently difficult to handle because
they involve circles with almost opposite directions at some vertices. Polygons
whose vertices come from some physical measurement with noise are also
difficult because an edge that should be straight may be broken in lots of
different pieces with almost equal directions. In both cases, computing the
circles intersections is not numerically robust due to the almost 0 or almost
π angle. Such cases need to carefully adjust the hyperplaneThickness
parameter. A too small value would often lead to completely wrong polygons
with large area wrongly identified as inside or outside. Large values are
often much safer. As a rule of thumb, a value slightly below the size of the
most accurate detail needed is a good value for the hyperplaneThickness
parameter.
hyperplaneThickness
 tolerance below which points are considered to
belong to the hyperplane (which is therefore more a slab). Should be greater than
FastMath.ulp(4 * FastMath.PI)
for meaningful results.vertices
 vertices of the simple loop boundaryMathIllegalArgumentException
 if tolerance is smaller than Sphere1D.SMALLEST_TOLERANCE
MathRuntimeException
 if vertices
contains only a single vertex or repeated vertices.public SphericalPolygonsSet buildNew(BSPTree<Sphere2D> tree)
This method allow to create new instances without knowing exactly the type of the region. It is an application of the prototype design pattern.
The leaf nodes of the BSP tree must have a
Boolean
attribute representing the inside status of
the corresponding cell (true for inside cells, false for outside
cells). In order to avoid building too many small objects, it is
recommended to use the predefined constants
Boolean.TRUE
and Boolean.FALSE
. The
tree also must have either null internal nodes or
internal nodes representing the boundary as specified in the
getTree
method).
protected void computeGeometricalProperties() throws MathIllegalStateException
The properties to compute are the barycenter and the size.
computeGeometricalProperties
in class AbstractRegion<Sphere2D,Sphere1D>
MathIllegalStateException
 if the tolerance setting does not allow to build
a clean nonambiguous boundarypublic List<Vertex> getBoundaryLoops() throws MathIllegalStateException
The polygon boundary can be represented as a list of closed loops, each loop being given by exactly one of its vertices. From each loop start vertex, one can follow the loop by finding the outgoing edge, then the end vertex, then the next outgoing edge ... until the start vertex of the loop (exactly the same instance) is found again once the full loop has been visited.
If the polygon has no boundary at all, a zero length loop array will be returned.
If the polygon is a simple onepiece polygon, then the returned array will contain a single vertex.
All edges in the various loops have the inside of the region on their left side (i.e. toward their pole) and the outside on their right side (i.e. away from their pole) when moving in the underlying circle direction. This means that the closed loops obey the direct trigonometric orientation.
MathIllegalStateException
 if the tolerance setting does not allow to build
a clean nonambiguous boundaryVertex
,
Edge
public EnclosingBall<Sphere2D,S2Point> getEnclosingCap()
This method is intended as a first test to quickly identify points
that are guaranteed to be outside of the region, hence performing a full
checkPoint
only if the point status remains undecided after the quick check. It is
is therefore mostly useful to speed up computation for small polygons with
complex shapes (say a country boundary on Earth), as the spherical cap will
be small and hence will reliably identify a large part of the sphere as outside,
whereas the full check can be more computing intensive. A typical use case is
therefore:
// compute region, plus an enclosing spherical cap SphericalPolygonsSet complexShape = ...; EnclosingBall<Sphere2D, S2Point> cap = complexShape.getEnclosingCap(); // check lots of points for (Vector3D p : points) { final Location l; if (cap.contains(p)) { // we cannot be sure where the point is // we need to perform the full computation l = complexShape.checkPoint(v); } else { // no need to do further computation, // we already know the point is outside l = Location.OUTSIDE; } // use l ... }
In the special cases of empty or whole sphere polygons, special
spherical caps are returned, with angular radius set to negative
or positive infinity so the ball.contains(point)
method return always false or true.
This method is not guaranteed to return the smallest enclosing cap.
Copyright © 20162021 CS GROUP. All rights reserved.