pub struct MonoPoly<T: GeoNum> { /* private fields */ }
Expand description
Monotone polygon
A monotone polygon is a polygon that can be decomposed into two monotone
chains (along the X-axis). This implies any vertical line intersects the
polygon at most twice (or not at all). These polygons support
point-in-polygon queries in O(log n)
time; use the Intersects<Coord>
trait to query.
This structure cannot be directly constructed. Use
crate::algorithm::monotone_subdivision
algorithm to obtain a
Vec<MonoPoly>
. Consider using MonotonicPolygons
instead if you are not
interested in the individual monotone polygons.
Implementations§
source§impl<T: GeoNum> MonoPoly<T>
impl<T: GeoNum> MonoPoly<T>
sourcepub fn top(&self) -> &LineString<T>
pub fn top(&self) -> &LineString<T>
Get a reference to the mono poly’s top chain.
sourcepub fn bot(&self) -> &LineString<T>
pub fn bot(&self) -> &LineString<T>
Get a reference to the mono poly’s bottom chain.
sourcepub fn into_ls_pair(self) -> (LineString<T>, LineString<T>)
pub fn into_ls_pair(self) -> (LineString<T>, LineString<T>)
Convert self to (top, bottom) pair of chains.
sourcepub fn bounding_segment(&self, x: T) -> Option<(Line<T>, Line<T>)>
pub fn bounding_segment(&self, x: T) -> Option<(Line<T>, Line<T>)>
Get the pair of segments in the chain that intersects the line parallel to the Y-axis at the given x-coordinate. Ties are broken by picking the segment with lower index, i.e. the segment closer to the start of the chains.
sourcepub fn into_polygon(self) -> Polygon<T>
pub fn into_polygon(self) -> Polygon<T>
Convert self into a Polygon
.