erlab.analysis.mask.polygon¶
Point-in-polygon algorithm.
The implementation has been adapted from the CGAL C++ library.
Functions
|
Compute if a point is inside, outside, or on the boundary of a polygon. |
|
Compute whether a point lies inside a polygon using |
|
Return the index of the leftmost point of a polygon. |
|
|
|
Return the index of the rightmost point of a polygon. |
|
Classes
|
|
|
- class erlab.analysis.mask.polygon.Comparison(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
- EQUAL = 0¶
- LARGER = 1¶
- SMALLER = -1¶
- class erlab.analysis.mask.polygon.Side(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
- ON_BOUNDARY = 0¶
- ON_BOUNDED_SIDE = 1¶
- ON_UNBOUNDED_SIDE = -1¶
- erlab.analysis.mask.polygon.bounded_side(points, point)[source]¶
Compute if a point is inside, outside, or on the boundary of a polygon.
The polygon is defined by the sequence of points [first,last). Being inside is defined by the odd-even rule. If the point is on a polygon edge, a special value is returned. A simple polygon divides the plane in an unbounded and a bounded region. According to the definition points in the bounded region are inside the polygon.
- Parameters:
- Returns:
Enum indicating the location of the point.
- Return type:
Note
We shoot a horizontal ray from the point to the right and count the number of intersections with polygon segments. If the number of intersections is odd, the point is inside. We don’t count intersections with horizontal segments. With non-horizontal segments, the top vertex is considered to be part of the segment, but the bottom vertex is not. (Segments are half-closed).
- erlab.analysis.mask.polygon.bounded_side_bool(points, point, boundary=True)[source]¶
Compute whether a point lies inside a polygon using
bounded_side
.
- erlab.analysis.mask.polygon.left_vertex(points)[source]¶
Return the index of the leftmost point of a polygon.
In case of a tie, the point with the smallest y-coordinate is taken.