![]() |
Pangolin
Header-only C++20 plane computational geometry library
|
Closed simple polygon stored by its vertices. More...
#include <polygon.hpp>
Classes | |
| class | BoundaryIterator |
| Forward iterator over the (optionally oriented) boundary edges. More... | |
Public Types | |
| using | PointType = PointType_ |
| using | NumberType = PointType::NumberType |
| using | LabelType = TLabel |
| template<bool Oriented> | |
| using | BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>> |
| using | EdgeIterator = BoundaryIterator<false> |
| using | OrientedEdgeIterator = BoundaryIterator<true> |
Public Member Functions | |
| constexpr | Polygon ()=default |
| Creates a polygon with no vertex. | |
| template<std::ranges::input_range Range = std::initializer_list<PointType>> requires std::ranges::common_range<Range> && std::convertible_to<std::ranges::range_value_t<Range>, PointType> | |
| constexpr | Polygon (Range &&points, bool trusted=false) |
| Creates a polygon from a range of points. | |
| constexpr | Polygon (std::initializer_list< NumberType > coords, bool trusted=false) |
| Creates a polygon from a flat list of coordinates. | |
| template<PointConcept OtherPointType, class OtherLabelType> requires (std::constructible_from<PointType, const OtherPointType&>) | |
| constexpr | Polygon (const Polygon< OtherPointType, OtherLabelType > &other) |
| Converts a polygon with compatible vertex type. | |
| template<class A = LabelType> requires (detail::has_label_v<A>) | |
| constexpr A & | label () const |
| Returns the polygon label. | |
| constexpr const PointType | operator[] (std::size_t index) const |
| Accesses a vertex by index. | |
| constexpr PointType | get (std::ptrdiff_t index) const |
| Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end. Useful for iterating polygon edges where the last edge wraps around. | |
| constexpr std::ptrdiff_t | index (const PointType &point) const |
| Returns the smallest index i with (*this)[i] == point, or -1 if point is not a vertex. | |
| constexpr auto | begin () const |
| Returns a constant iterator to the first vertex. | |
| constexpr auto | cbegin () const |
| Returns a constant iterator to the first vertex. | |
| constexpr auto | end () const |
| Returns a constant iterator past the last vertex. | |
| constexpr auto | cend () const |
| Returns a constant iterator past the last vertex. | |
| constexpr auto | operator<=> (const Polygon &other) const |
| Compares two polygons by their canonical vertex sequences. | |
| constexpr bool | operator== (const Polygon &other) const |
| Checks equality of two polygons. | |
| template<AnyShapeConcept OtherShape> | |
| constexpr bool | samePointSet (const OtherShape &other) const |
| Tests whether another shape defines exactly the same point set. | |
| constexpr std::size_t | size () const |
| Returns the number of vertices in the polygon. | |
| template<class ResultNumber = NumberType> | |
| constexpr ResultNumber | twiceArea () const |
| Computes twice the (unsigned) area of the polygon via the shoelace formula. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr auto | area () const |
| Computes the area of the polygon. | |
| constexpr bool | empty () const |
| Returns whether the polygon is the empty set of points. | |
| constexpr bool | isDegenerate () const |
| Checks if the polygon is degenerate (has zero area). | |
| constexpr bool | isPoint () const |
| Checks whether the polygon covers exactly one point. | |
| constexpr std::optional< PointType > | getIfPoint () const |
| Returns the point the polygon collapses to, if it does. | |
| constexpr bool | isSegment () const |
| Checks whether the polygon covers exactly one segment of positive length. | |
| constexpr std::optional< BoundaryType< false > > | getIfSegment () const |
| Returns the segment the polygon collapses to, if it does. | |
| constexpr bool | isUndefined () const |
| Checks whether the polygon is degenerate without covering a point or a segment. | |
| template<class Rational = pgl::Rational<pgl::BigInt>> | |
| bool | isSimple () const |
| Tests whether the polygon is simple (its boundary does not touch or cross itself). | |
| constexpr bool | isConvex () const |
| Tests whether the polygon is convex. | |
| constexpr std::size_t | chainCount () const |
| Counts the maximal lexicographically monotone chains the boundary decomposes into, without building any of them. | |
| constexpr std::optional< HalfplaneIntersection< PointType > > | getStarShapedKernel () const |
| Returns the kernel: the set of points that see the whole polygon. | |
| constexpr bool | isStarShaped () const |
| Tests whether the polygon is star-shaped. | |
| constexpr Segment< PointType > | diameter () const |
| Returns a segment realizing the diameter (the farthest vertex pair). | |
| constexpr Convex< PointType > | convexHull () const |
| Returns the convex hull of the polygon's vertices. | |
| constexpr const Rectangle< PointType > & | bbox () const |
| Computes the bounding box of the polygon. | |
| template<class ResultNumber = grid_number_t<typename PointType_::NumberType>> requires (detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>) | |
| std::vector< Point< ResultNumber, typename PointType::LabelType > > | latticePoints () const |
| Returns the integer points the polygon contains. | |
| template<std::floating_point ResultNumber = double> | |
| constexpr Rectangle< Point< ResultNumber > > | fbox () const |
| Computes the floating-point bounding box of the polygon. | |
| constexpr std::vector< PointType > | vertices () const |
| Returns the vertices of the polygon (translation applied). | |
| constexpr std::vector< Segment< PointType > > | edges () const |
| Returns the edges of the polygon. | |
| constexpr std::vector< OrientedSegment< PointType > > | orientedEdges () const |
| Returns the oriented edges of the polygon. | |
| Graph< PointType > | visibilityGraph () const |
| Returns the visibility graph of the polygon vertices. | |
| Graph< PointType > | clearVisibilityGraph () const |
| Returns the clear visibility graph of the polygon vertices. | |
| Graph< PointType > | reducedVisibilityGraph () const |
| Returns the reduced visibility graph of the polygon vertices. | |
| std::vector< PointType > | visibleVertices (const PointType &query) const |
The polygon vertices visible from query. | |
| std::vector< PointType > | clearlyVisibleVertices (const PointType &query) const |
The polygon vertices clearly visible from query. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| Polygon< Point< ResultNumber > > | regularizedVisiblePolygon (const PointType &query) const |
The part of the polygon visible from query, regularized. | |
| constexpr auto | verticesView () const |
| Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector. | |
| constexpr auto | edgesView () const |
| Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vector. | |
| constexpr auto | orientedEdgesView () const |
| Lazy view counterpart of orientedEdges(); see edgesView(). | |
| constexpr EdgeIterator | edgesBegin () const |
| Returns an iterator to the first unoriented edge. | |
| constexpr EdgeIterator | edgesEnd () const |
| Returns an iterator past the last unoriented edge. | |
| constexpr OrientedEdgeIterator | orientedEdgesBegin () const |
| Returns an iterator to the first oriented edge. | |
| constexpr OrientedEdgeIterator | orientedEdgesEnd () const |
| Returns an iterator past the last oriented edge. | |
| constexpr PolygonWithHoles< PointType > | asPolygonWithHoles () const |
| Returns the polygon as a hole-free region. | |
| constexpr PolygonSet< PointType > | asPolygonSet () const |
| Returns the polygon as a one-component set of regions. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Point< ResultNumber > | centroid () const |
| Computes the area-weighted centroid of the polygon. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Point< ResultNumber > | verticesCentroid () const |
| Computes the centroid of the vertex set (the average of the vertices). | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Point< ResultNumber > | pointInside () const |
| Returns a point strictly inside the (simple) polygon. | |
| template<class OtherShape> | |
| constexpr bool | pointInsideInteriorContainedIn (const OtherShape &shape) const |
Tests whether some point in this shape's relative interior lies in the strict interior of shape. | |
| auto | triangulation () const |
| Builds the constrained Delaunay triangulation of this polygon. | |
| template<class SegmentRange> | |
| auto | triangulation (const SegmentRange &segments) const |
| Builds the constrained Delaunay triangulation of this polygon with the given interior constraint segments. | |
| std::vector< Convex< PointType > > | convexPartition () const |
| Cuts this polygon into convex pieces with disjoint interiors. | |
| std::vector< Convex< PointType > > | convexCovering () const |
| Covers this polygon with convex hulls derived from triangle cliques. | |
| template<class ResultNumber = grid_number_t<typename PointType_::NumberType>> requires (std::signed_integral<ResultNumber>) | |
| auto | asBitMatrix () const |
| Rasterizes this polygon into a BitMatrix, one bit per covered cell. | |
| template<class PointRange, class SegmentRange> | |
| auto | triangulation (const PointRange &points, const SegmentRange &segments) const |
| Builds the constrained Delaunay triangulation of this polygon with the given interior vertices and constraint segments. | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherPolygon &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherConvex &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherTriangle &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherRectangle &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherRegion &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherSet &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherIntersection &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | difference (const OtherHalfplane &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | regularizedUnion (const OtherPolygon &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | regularizedUnion (const OtherConvex &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | regularizedUnion (const OtherTriangle &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | regularizedUnion (const OtherRectangle &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | regularizedUnion (const OtherRegion &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet> | |
| auto | regularizedUnion (const OtherSet &other) const |
| Returns the regularized union of the two shapes (A ∪ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | symmetricDifference (const OtherPolygon &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | symmetricDifference (const OtherConvex &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | symmetricDifference (const OtherTriangle &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | symmetricDifference (const OtherRectangle &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | symmetricDifference (const OtherRegion &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet> | |
| auto | symmetricDifference (const OtherSet &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherPolygon &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherConvex &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherTriangle &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherRectangle &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherRegion &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherPolyline &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherChain &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherSegment &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherSegment> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherSegment &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet> | |
| PolygonSet< Point< ResultNumber, typename PointType::LabelType > > | minkowskiSum (const OtherSet &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B), as a set of regions. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | contains (const OtherPoint &point) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | contains (const OtherSegment &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | contains (const OtherOrientedSegment &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<LineConcept OtherLine> | |
| constexpr bool | contains (const OtherLine &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | contains (const OtherOrientedLine &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<RayConcept OtherRay> | |
| constexpr bool | contains (const OtherRay &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | contains (const OtherHalfplane &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | contains (const OtherRectangle &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | contains (const OtherTriangle &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | contains (const OtherConvex &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | contains (const OtherPolygon &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | containsChainBased (const OtherPolygon &other) const |
| Same contract as contains(const OtherPolygon&) const, by the chain-pair strategy alone. | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | contains (const OtherDisk &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| constexpr bool | contains (const Shape< PointType > &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<class EmptyPoint> | |
| constexpr bool | contains (const EmptyShape< EmptyPoint > &) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<class EmptyPoint> | |
| constexpr bool | boundaryContains (const EmptyShape< EmptyPoint > &) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<class EmptyPoint> | |
| constexpr bool | interiorContains (const EmptyShape< EmptyPoint > &) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | interiorContains (const OtherPoint &point) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | interiorContains (const OtherSegment &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | interiorContainsInterior (const OtherSegment &other) const |
| Tests whether this shape's interior contains the segment's interior. | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | interiorContains (const OtherOrientedSegment &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<LineConcept OtherLine> | |
| constexpr bool | interiorContains (const OtherLine &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | interiorContains (const OtherOrientedLine &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<RayConcept OtherRay> | |
| constexpr bool | interiorContains (const OtherRay &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | interiorContains (const OtherHalfplane &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | interiorContains (const OtherRectangle &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | interiorContains (const OtherTriangle &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | interiorContains (const OtherConvex &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | interiorContains (const OtherPolygon &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | boundaryContains (const OtherPoint &point) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | boundaryContains (const OtherSegment &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | boundaryContains (const OtherOrientedSegment &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<LineConcept OtherLine> | |
| constexpr bool | boundaryContains (const OtherLine &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | boundaryContains (const OtherOrientedLine &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<RayConcept OtherRay> | |
| constexpr bool | boundaryContains (const OtherRay &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | boundaryContains (const OtherHalfplane &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | boundaryContains (const OtherRectangle &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | boundaryContains (const OtherTriangle &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | boundaryContains (const OtherConvex &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | boundaryContains (const OtherPolygon &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | boundaryContains (const OtherDisk &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | boundaryContains (const Shape< OtherPoint > &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | interiorContains (const OtherDisk &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | separates (const OtherPoint &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | separates (const OtherHalfplane &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | separates (const OtherRectangle &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | separates (const OtherTriangle &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | separates (const OtherDisk &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | separates (const OtherConvex &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | separates (const OtherPolygon &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | contains (const OtherChain &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | boundaryContains (const OtherChain &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | interiorContains (const OtherChain &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | intersects (const OtherChain &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | interiorsIntersect (const OtherChain &other) const |
| Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | separates (const OtherChain &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<MonotoneChainConcept OtherChain> | |
| constexpr bool | crosses (const OtherChain &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain> | |
| constexpr auto | squaredDistance (const OtherChain &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain> | |
| constexpr auto | distanceL1 (const OtherChain &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain> | |
| constexpr auto | distanceLInf (const OtherChain &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | contains (const OtherPolyline &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | boundaryContains (const OtherPolyline &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | interiorContains (const OtherPolyline &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | intersects (const OtherPolyline &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | interiorsIntersect (const OtherPolyline &other) const |
| Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | separates (const OtherPolyline &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<HalfplaneIntersectionConcept OtherRegion> | |
| constexpr bool | contains (const OtherRegion &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<HalfplaneIntersectionConcept OtherRegion> | |
| constexpr bool | boundaryContains (const OtherRegion &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<HalfplaneIntersectionConcept OtherRegion> | |
| constexpr bool | interiorContains (const OtherRegion &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<HalfplaneIntersectionConcept OtherRegion> | |
| constexpr bool | separates (const OtherRegion &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PolygonWithHolesConcept OtherRegion> | |
| constexpr bool | contains (const OtherRegion &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolygonWithHolesConcept OtherRegion> | |
| constexpr bool | boundaryContains (const OtherRegion &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PolygonWithHolesConcept OtherRegion> | |
| constexpr bool | interiorContains (const OtherRegion &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PolygonWithHolesConcept OtherRegion> | |
| bool | separates (const OtherRegion &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PolygonSetConcept OtherSet> | |
| constexpr bool | contains (const OtherSet &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolygonSetConcept OtherSet> | |
| constexpr bool | boundaryContains (const OtherSet &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PolygonSetConcept OtherSet> | |
| constexpr bool | interiorContains (const OtherSet &other) const |
| Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B). | |
| template<PolygonSetConcept OtherSet> | |
| bool | separates (const OtherSet &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PolylineConcept OtherPolyline> | |
| constexpr bool | crosses (const OtherPolyline &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline> | |
| constexpr auto | squaredDistance (const OtherPolyline &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline> | |
| constexpr auto | distanceL1 (const OtherPolyline &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline> | |
| constexpr auto | distanceLInf (const OtherPolyline &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | intersects (const OtherPoint &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | intersects (const OtherSegment &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | intersects (const OtherOrientedSegment &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<LineConcept OtherLine> | |
| constexpr bool | intersects (const OtherLine &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | intersects (const OtherOrientedLine &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<RayConcept OtherRay> | |
| constexpr bool | intersects (const OtherRay &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | intersects (const OtherHalfplane &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | intersects (const OtherRectangle &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | intersects (const OtherTriangle &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | intersects (const OtherConvex &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | intersects (const OtherPolygon &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | boundariesIntersect (const OtherPolygon &other) const |
| Tests whether the two polygon boundaries share at least one point (∂A ∩ ∂B ≠ ∅). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | boundariesStrongCross (const OtherPolygon &other) const |
| Tests whether the two polygon boundaries have mononotone chains that strong cross. | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | intersects (const OtherDisk &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | interiorsIntersect (const OtherPoint &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<LineConcept OtherLine> | |
| constexpr bool | interiorsIntersect (const OtherLine &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | interiorsIntersect (const OtherOrientedLine &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | interiorsIntersect (const OtherSegment &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | interiorsIntersect (const OtherOrientedSegment &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<RayConcept OtherRay> | |
| constexpr bool | interiorsIntersect (const OtherRay &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | interiorsIntersect (const OtherHalfplane &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | interiorsIntersect (const OtherRectangle &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | interiorsIntersect (const OtherTriangle &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | interiorsIntersect (const OtherConvex &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | interiorsIntersect (const OtherPolygon &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | interiorsIntersect (const OtherDisk &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | separates (const OtherSegment &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | separates (const OtherOrientedSegment &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<RayConcept OtherRay> | |
| constexpr bool | separates (const OtherRay &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<LineConcept OtherLine> | |
| constexpr bool | separates (const OtherLine &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | separates (const OtherOrientedLine &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | crosses (const OtherPoint &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | crosses (const OtherSegment &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | crosses (const OtherOrientedSegment &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<RayConcept OtherRay> | |
| constexpr bool | crosses (const OtherRay &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<LineConcept OtherLine> | |
| constexpr bool | crosses (const OtherLine &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | crosses (const OtherOrientedLine &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | crosses (const OtherHalfplane &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | crosses (const OtherRectangle &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | crosses (const OtherTriangle &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | crosses (const OtherConvex &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | crosses (const OtherDisk &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | crosses (const OtherPolygon &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | crosses (const Shape< OtherPoint > &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | intersects (const Shape< OtherPoint > &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | interiorsIntersect (const Shape< OtherPoint > &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<typename OtherShape> requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) | |
| constexpr bool | crosses (const OtherShape &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<typename OtherShape> requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) | |
| constexpr bool | intersects (const OtherShape &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<typename OtherShape> requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) | |
| constexpr bool | interiorsIntersect (const OtherShape &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<class EmptyPoint> | |
| constexpr bool | crosses (const EmptyShape< EmptyPoint > &) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<class EmptyPoint> | |
| constexpr bool | intersects (const EmptyShape< EmptyPoint > &) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<class EmptyPoint> | |
| constexpr bool | interiorsIntersect (const EmptyShape< EmptyPoint > &) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | squaredDistance (const OtherPoint &point) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr auto | squaredDistance (const OtherSegment &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr auto | squaredDistance (const OtherOrientedSegment &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine> | |
| constexpr auto | squaredDistance (const OtherLine &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine> | |
| constexpr auto | squaredDistance (const OtherOrientedLine &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay> | |
| constexpr auto | squaredDistance (const OtherRay &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane> | |
| constexpr auto | squaredDistance (const OtherHalfplane &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| constexpr auto | squaredDistance (const OtherRectangle &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| constexpr auto | squaredDistance (const OtherTriangle &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| constexpr auto | squaredDistance (const OtherConvex &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| constexpr auto | squaredDistance (const OtherPolygon &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) && requires(const OtherShape& o, const Polygon& self) { o.template squaredDistance<ResultNumber>(self); }) | |
| constexpr auto | squaredDistance (const OtherShape &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = double, class DiskPointType, class DiskLabel> | |
| detail::floating_result_t< ResultNumber > | squaredDistance (const Disk< DiskPointType, DiskLabel > &disk) const |
| Returns the squared Euclidean distance to a disk. | |
| template<class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape> requires detail::ClosestPairConcept<Polygon<PointType_, TLabel>, OtherShape> | |
| constexpr auto | closestSegments (const OtherShape &other) const |
| Returns the pair of elements realizing the distance, nothing when the shapes meet. | |
| template<class ResultNumber = division_result_t<NumberType>, class OtherShape> requires detail::ClosestPointsPairConcept<Polygon<PointType_, TLabel>, OtherShape> | |
| constexpr auto | closestPoints (const OtherShape &other) const |
| Returns the pair of points realizing the distance, nothing when the shapes meet. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | distanceL1 (const OtherPoint &point) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr auto | distanceL1 (const OtherSegment &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr auto | distanceL1 (const OtherOrientedSegment &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine> | |
| constexpr auto | distanceL1 (const OtherLine &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine> | |
| constexpr auto | distanceL1 (const OtherOrientedLine &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay> | |
| constexpr auto | distanceL1 (const OtherRay &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane> | |
| constexpr auto | distanceL1 (const OtherHalfplane &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| constexpr auto | distanceL1 (const OtherRectangle &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| constexpr auto | distanceL1 (const OtherTriangle &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| constexpr auto | distanceL1 (const OtherConvex &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| constexpr auto | distanceL1 (const OtherPolygon &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) && requires(const OtherShape& o, const Polygon& self) { o.template distanceL1<ResultNumber>(self); }) | |
| constexpr auto | distanceL1 (const OtherShape &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | intersection (const Shape< OtherPoint > &other) const |
| Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersection. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| auto | regularizedIntersection (const Shape< OtherPoint > &other) const |
| Re-dispatches a regularized intersection through a runtime shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| auto | regularizedUnion (const Shape< OtherPoint > &other) const |
| Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own regularizedUnion. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| auto | difference (const Shape< OtherPoint > &other) const |
| Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper's own difference. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| auto | symmetricDifference (const Shape< OtherPoint > &other) const |
| Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wrapper's own symmetricDifference. | |
| template<class ResultNumber = double, PointConcept OtherPoint> | |
| constexpr auto | distanceL1 (const Shape< OtherPoint > &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | distanceLInf (const OtherPoint &point) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr auto | distanceLInf (const OtherSegment &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr auto | distanceLInf (const OtherOrientedSegment &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine> | |
| constexpr auto | distanceLInf (const OtherLine &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine> | |
| constexpr auto | distanceLInf (const OtherOrientedLine &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay> | |
| constexpr auto | distanceLInf (const OtherRay &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane> | |
| constexpr auto | distanceLInf (const OtherHalfplane &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| constexpr auto | distanceLInf (const OtherRectangle &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| constexpr auto | distanceLInf (const OtherTriangle &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| constexpr auto | distanceLInf (const OtherConvex &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| constexpr auto | distanceLInf (const OtherPolygon &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) && requires(const OtherShape& o, const Polygon& self) { o.template distanceLInf<ResultNumber>(self); }) | |
| constexpr auto | distanceLInf (const OtherShape &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = double, PointConcept OtherPoint> | |
| constexpr auto | distanceLInf (const Shape< OtherPoint > &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = NumberType, PointConcept OtherPoint> | |
| constexpr std::optional< Point< ResultNumber, typename PointType::LabelType > > | intersection (const OtherPoint &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherSegment &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherOrientedSegment &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherLine &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherOrientedLine &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherRay &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherPolygon &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherConvex &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherTriangle &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherRectangle &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) && requires(const OtherShape& o, const Polygon& self) { o.template intersection<ResultNumber>(self); }) | |
| auto | intersection (const OtherShape &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Polygon>) && requires(const OtherShape& o, const Polygon& self) { o.template regularizedIntersection<ResultNumber>(self); }) | |
| auto | regularizedIntersection (const OtherShape &other) const |
| Forwards a regularized intersection to the shape that owns it. | |
| template<class ResultNumber = NumberType, class EmptyPoint> | |
| constexpr EmptyShape< EmptyPoint > | intersection (const EmptyShape< EmptyPoint > &) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane> | |
| constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Polygon< Point< ResultNumber, typename PointType::LabelType > > > > | intersection (const OtherHalfplane &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline> | |
| constexpr auto | intersection (const OtherPolyline &other) const |
| Returns the intersection with an open polyline (A ∩ B), a sequence of points and segments. | |
| template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain> | |
| constexpr auto | intersection (const OtherChain &other) const |
| Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments. | |
| constexpr Polygon | rotated90 (int k=1) const |
| Returns the polygon rotated by 90k degrees around the origin. | |
| constexpr void | rotate90 (int k=1) |
| Rotates the polygon by 90k degrees around the origin in place. | |
| constexpr void | untangle () |
| Makes the polygon simple in place by uncrossing its boundary. | |
| template<class OtherNumber> | |
| constexpr Polygon | scaledUpX (const OtherNumber scalar) const |
| Returns the polygon with its x-coordinates multiplied by a factor. | |
| template<class OtherNumber> | |
| constexpr void | scaleUpX (const OtherNumber scalar) |
| Multiplies the polygon's x-coordinates by a factor in place. | |
| template<class OtherNumber> | |
| constexpr Polygon | scaledUpY (const OtherNumber scalar) const |
| Returns the polygon with its y-coordinates multiplied by a factor. | |
| template<class OtherNumber> | |
| constexpr void | scaleUpY (const OtherNumber scalar) |
| Multiplies the polygon's y-coordinates by a factor in place. | |
| template<class OtherNumber> | |
| constexpr Polygon | scaledDownX (const OtherNumber scalar) const |
| Returns the polygon with its x-coordinates divided by a divisor. | |
| template<class OtherNumber> | |
| constexpr void | scaleDownX (const OtherNumber scalar) |
| Divides the polygon's x-coordinates by a divisor in place. | |
| template<class OtherNumber> | |
| constexpr Polygon | scaledDownY (const OtherNumber scalar) const |
| Returns the polygon with its y-coordinates divided by a divisor. | |
| template<class OtherNumber> | |
| constexpr void | scaleDownY (const OtherNumber scalar) |
| Divides the polygon's y-coordinates by a divisor in place. | |
| template<class OtherShape> requires MinkowskiSummableConcept<Polygon<PointType_, TLabel>, OtherShape> | |
| constexpr auto | minkowskiSum (const OtherShape &other) const |
| Returns the Minkowski sum of this shape and another (A ⊕ B). | |
| template<class OtherShape> requires MinkowskiSummableConcept<Polygon<PointType_, TLabel>, OtherShape> | |
| constexpr auto | minkowskiErosion (const OtherShape &other) const |
| Returns the Minkowski erosion of this shape by another (A ⊖ B). | |
| template<class ResultNumber = division_result_t<NumberType>, class OtherShape> requires (!MinkowskiSummableConcept<Polygon<PointType_, TLabel>, OtherShape> && BoundedPolygonalConcept<OtherShape>) | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiErosion (const OtherShape &other) const |
| Returns the regularized Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B), as a set of regions. | |
| template<PointConcept OtherPoint> | |
| constexpr Polygon & | operator+= (const OtherPoint &translation) |
| Translates the polygon by the given point. | |
| template<PointConcept OtherPoint> | |
| constexpr Polygon & | operator-= (const OtherPoint &translation) |
| Translates the polygon by the negation of the given point. | |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Polygon & | operator*= (const Scalar &scalar) |
| Scales the polygon by the given scalar. | |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Polygon & | operator/= (const Scalar &scalar) |
| Divides the polygon by the given scalar. | |
| template<class ResultNumber, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherPolygon &other) const |
| template<class ResultNumber, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherConvex &other) const |
| template<class ResultNumber, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherTriangle &other) const |
| template<class ResultNumber, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherRectangle &other) const |
| template<class ResultNumber, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherRegion &other) const |
| template<class ResultNumber, PolygonSetConcept OtherSet> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherSet &other) const |
| template<class ResultNumber, HalfplaneIntersectionConcept OtherIntersection> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherIntersection &other) const |
| template<class ResultNumber, HalfplaneConcept OtherHalfplane> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | difference (const OtherHalfplane &other) const |
| template<class ResultNumber, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | regularizedUnion (const OtherPolygon &other) const |
| template<class ResultNumber, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | regularizedUnion (const OtherConvex &other) const |
| template<class ResultNumber, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | regularizedUnion (const OtherTriangle &other) const |
| template<class ResultNumber, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | regularizedUnion (const OtherRectangle &other) const |
| template<class ResultNumber, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | regularizedUnion (const OtherRegion &other) const |
| template<class ResultNumber, PolygonConcept OtherPolygon> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | symmetricDifference (const OtherPolygon &other) const |
| template<class ResultNumber, ConvexConcept OtherConvex> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | symmetricDifference (const OtherConvex &other) const |
| template<class ResultNumber, TriangleConcept OtherTriangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | symmetricDifference (const OtherTriangle &other) const |
| template<class ResultNumber, RectangleConcept OtherRectangle> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | symmetricDifference (const OtherRectangle &other) const |
| template<class ResultNumber, PolygonWithHolesConcept OtherRegion> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | symmetricDifference (const OtherRegion &other) const |
| template<class ResultNumber, PolygonConcept OtherPolygon> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherPolygon &other) const |
| template<class ResultNumber, ConvexConcept OtherConvex> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherConvex &other) const |
| template<class ResultNumber, TriangleConcept OtherTriangle> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherTriangle &other) const |
| template<class ResultNumber, RectangleConcept OtherRectangle> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherRectangle &other) const |
| template<class ResultNumber, PolygonWithHolesConcept OtherRegion> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherRegion &other) const |
| template<class ResultNumber, SegmentConcept OtherSegment> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherSegment &other) const |
| template<class ResultNumber, OrientedSegmentConcept OtherOriented> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherOriented &other) const |
| template<class ResultNumber, PolylineConcept OtherPolyline> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherPolyline &other) const |
| template<class ResultNumber, MonotoneChainConcept OtherChain> | |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherChain &other) const |
| template<class ResultNumber, PolygonSetConcept OtherSet> | |
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > | minkowskiSum (const OtherSet &other) const |
| template<class OtherNumber> | |
| constexpr Polygon< PointType, LabelType > | scaledUpX (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Polygon< PointType, LabelType > | scaledUpY (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Polygon< PointType, LabelType > | scaledDownX (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Polygon< PointType, LabelType > | scaledDownY (const OtherNumber scalar) const |
Closed simple polygon stored by its vertices.
A simple polygon stored by its vertices plus a translation.
Polygon mirrors the storage layout of Convex — a vector of vertices and a translation_ applied lazily on access — but makes no convexity assumption. The boundary is the closed polyline through the vertices in the stored order, with the last vertex joined back to the first.
The constructor normalizes the vertex sequence to a canonical form: it is oriented counterclockwise and rotated so the lexicographically smallest vertex (smallest x, ties broken by smallest y) comes first. Because a constant translation preserves both orientation and lexicographic order, operator==/operator<=> give a translation-consistent geometric equality.
| PointType_ | The vertex point type. |
| using pgl::Polygon< PointType_, TLabel >::BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>> |
| using pgl::Polygon< PointType_, TLabel >::EdgeIterator = BoundaryIterator<false> |
| using pgl::Polygon< PointType_, TLabel >::LabelType = TLabel |
| using pgl::Polygon< PointType_, TLabel >::NumberType = PointType::NumberType |
| using pgl::Polygon< PointType_, TLabel >::OrientedEdgeIterator = BoundaryIterator<true> |
| using pgl::Polygon< PointType_, TLabel >::PointType = PointType_ |
|
constexprdefault |
Creates a polygon with no vertex.
|
inlineexplicitconstexpr |
Creates a polygon from a range of points.
The points must be given in the order they appear along the boundary. Unless trusted is set, the vertices are normalized to the canonical form (counterclockwise, lexicographically smallest vertex first).
| Range | Input range whose elements can be converted to PointType. |
| points | Range of boundary points in order. |
| trusted | Set to true if the points are already in canonical form. |
|
inlineexplicitconstexpr |
Creates a polygon from a flat list of coordinates.
The values are consumed in pairs (x0, y0, x1, y1, …), each pair forming one boundary vertex in order, so the list must hold an even number of values. Unless trusted is set, the vertices are normalized to the canonical form (counterclockwise, lexicographically smallest vertex first).
| coords | Interleaved x/y coordinates of the boundary vertices. |
| trusted | Set to true if the points are already in canonical form. |
|
inlineconstexpr |
Converts a polygon with compatible vertex type.
The source is already canonical and a translation/type conversion preserves that, so no renormalization is needed.
| OtherPointType | Source vertex type. |
| other | Source polygon. |
|
inlineconstexpr |
Computes the area of the polygon.
|
nodiscard |
Rasterizes this polygon into a BitMatrix, one bit per covered cell.
Equivalent to BitMatrix(*this): the window is the bounding box and the set cells are the ones the polygon covers. Only a rectilinear polygon is exactly a set of grid cells, so every edge must be axis-parallel; use innerRaster or outerRaster to approximate any other polygon.
A cell is an integer position, so the coordinates must be whole numbers too. An integer polygon rasterizes as it stands; one over a Rational or a floating-point type is checked vertex by vertex and throws unless every coordinate happens to be whole – rounding one would move the polygon.
| ResultNumber | Integer coordinate type of the grid (default: the coordinate type itself when it is a signed integer, the integer a Rational is built on, and int64_t otherwise). |
| std::logic_error | If an edge is not axis-parallel, or a coordinate is not a whole number the grid can hold. |
|
inlinenodiscardconstexpr |
Returns the polygon as a one-component set of regions.
A polygon with no area covers nothing that survives regularization, so it gives back the empty set rather than a component without area.
|
inlinenodiscardconstexpr |
Returns the polygon as a hole-free region.
The boundary is already canonical, and a region without holes needs no further normalization.
|
constexpr |
Computes the bounding box of the polygon.
Unlike Convex::bbox, a simple polygon has no monotone boundary structure to exploit, so the corners come from a linear scan. The result is computed on the first call and cached in bbox_; later calls return the stored value. Any operation that modifies the polygon resets the cache.
Complexity: O(n) for n vertices on the first call, O(1) thereafter.
|
inlineconstexpr |
Returns a constant iterator to the first vertex.
|
nodiscardconstexpr |
Tests whether the two polygon boundaries share at least one point (∂A ∩ ∂B ≠ ∅).
Decomposes each boundary into its maximal lexicographically monotone chains — MonotoneChainView spans into one buffer per polygon — and tests them with MonotoneChain's linear merge sweep. The two decompositions are produced in lockstep and every newly produced chain is tested against all already-produced chains of the other polygon, so all computed pairs are covered before the next chain is built and the search stops at the first shared point. This underlies both intersects and interiorsIntersect, which add the interior reasoning on top.
|
nodiscardconstexpr |
Tests whether the two polygon boundaries have mononotone chains that strong cross.
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Complexity: O(n) per edge for n vertices.
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
A boundary has no area, so it holds only a region with no area — which is exactly the union of that region's ring edges.
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
True iff the segment lies within a single boundary edge (the simple-polygon model also used by Convex::boundaryContains).
Complexity: O(n) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Complexity: O(n) per edge for n vertices.
|
constexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlineconstexpr |
Returns a constant iterator to the first vertex.
|
inlineconstexpr |
Returns a constant iterator past the last vertex.
|
inlineconstexpr |
Computes the area-weighted centroid of the polygon.
| ResultNumber | The number type for the result. |
|
inlinenodiscardconstexpr |
Counts the maximal lexicographically monotone chains the boundary decomposes into, without building any of them.
Consecutive boundary vertices of a simple polygon are distinct, so every edge runs strictly lex-up or lex-down and the boundary breaks into chains exactly at the vertices where that direction reverses. Counting those reversals is one pass and no allocation, and it returns precisely the number of chains BoundaryChains would produce: two for a convex polygon, up to n for a comb or a star, and zero for a boundary collapsed to a single point (no reversal exists there).
The count is what the chain-pair boundary tests pay for quadratically, so it is the input the sweep-versus-chains dispatch reads (see preferSweep).
Complexity: O(n) for n vertices.
|
nodiscard |
The polygon vertices clearly visible from query.
The strict counterpart of visibleVertices, matching clearVisibilityGraph: the open segment query–v must lie in the interior of the polygon and hold no other vertex, so neither grazing nor passing through a vertex counts. Always a subset of visibleVertices.
| query | Point to look from; outside the polygon nothing is visible. |
|
nodiscard |
Returns the clear visibility graph of the polygon vertices.
Two vertices are adjacent exactly when the open segment joining them lies in the interior of the polygon and contains no other vertex — the strict reading of visibility, which admits neither grazing nor passing through a vertex. The polygon's own sides are therefore absent, their relative interiors lying on the boundary, and what remains is exactly the set of legal triangulation diagonals. Always a subgraph of visibilityGraph.
The answer is meaningful for a simple polygon. A degenerate polygon has no interior, so its vertices come back with no edges at all.
Complexity: as visibilityGraph, with no convex shortcut.
|
nodiscardconstexpr |
Returns the pair of points realizing the distance, nothing when the shapes meet.
The first point lies on this shape and the second on other. Empty exactly when squaredDistance is zero. Unlike closestSegments this also takes an unbounded convex other — a line, an oriented line, a ray, a half-plane, a half-plane intersection — which realizes the distance at a point on no edge and at no vertex: there is no element to name there, but there is still a point to give.
| ResultNumber | Coordinate type of the returned points (default: division_result_t). |
ResultNumber it truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
nodiscardconstexpr |
Returns the pair of elements realizing the distance, nothing when the shapes meet.
The first element is this shape's, the second is other's; each is one of the shape's edges, degenerate to a vertex where the shape has none. Empty exactly when squaredDistance is zero.
| ResultNumber | Coordinate type of the returned segments (default: NumberType). |
other's coordinates and labels are re-expressed in this shape's, so a narrower ResultNumber loses them.
|
inlinenodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Complexity: O((n + m) log n) for n and m vertices.
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
A non-degenerate closed disk lies in the closed polygon iff its center is contained and no boundary edge cuts into the open disk (so the disk cannot poke out through a reflex notch). A degenerate disk reduces to a segment.
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Complexity: O(n log n) for n vertices.
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Uses an exact winding-number test, preceded by an explicit boundary check so the closed boundary counts as contained.
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
For simple polygons (no holes) this holds iff every edge of other is contained, which is what this checks.
Complexity: O((n + m) log n) for n and m vertices.
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Complexity: O(n log n) for n vertices.
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
A region is contained exactly when its outer polygon is: the region holds the whole outer ring whatever its holes do, and this shape has a connected complement. See implementation/contains.hpp.
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
The segment is split at its boundary intersections and each piece is classified by its midpoint, so the test is correct for non-convex polygons (both endpoints inside does not suffice).
Complexity: O(n log n) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Complexity: O(n log n) for n vertices.
|
constexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
constexpr |
Same contract as contains(const OtherPolygon&) const, by the chain-pair strategy alone.
Reaches the same answer by testing this polygon's and other's lexicographically monotone chains (see BoundaryChains) against each other pairwise instead of running a combined plane sweep. Cheaper when both boundaries are near-convex (few chains), since its cost is the product of the two chain counts; that product degrades to O(n * m) on a jagged, comb-like or star-shaped boundary, where sweepContains stays at O((n + m) log(n + m)) regardless.
contains calls whichever of the two preferSweep judges cheaper for the operands at hand, so reach for it rather than this; naming this one commits to the chain strategy even where the sweep would win by two orders of magnitude. It stays public so a benchmark can time the two strategies against each other over the same inputs.
Complexity: O(chains(A) * chains(B) * average chain length), i.e. O(n) for near-convex input and O(n * m) in the worst case.
|
nodiscard |
Covers this polygon with convex hulls derived from triangle cliques.
The polygon is triangulated and the paper's dual-graph BFS builds a full-visibility subgraph: triangles are graph vertices and every edge certifies that the endpoints' joint convex hull lies in the polygon. A DSATUR vertex clique cover is then converted into convex pieces by taking the hull of every clique. This is the Delaunay-partition variant of the clique-cover construction of Abrahamsen, Meyling, and Nusser (SoCG 2023).
The polygon has the same precondition as triangulation: simple and non-degenerate. Every piece is contained in this polygon and their union is the polygon, but unlike convexPartition their interiors may overlap. Redundant pieces are removed; the result is not necessarily a minimum-cardinality cover.
A convex polygon comes back as a single piece.
Complexity: O(n^3 log n) worst-case time and O(n^2) space for n polygon vertices; the dual search usually avoids most of the quadratic candidate pairs even though the worst-case bound is unchanged.
|
inlineconstexpr |
Returns the convex hull of the polygon's vertices.
|
nodiscard |
Cuts this polygon into convex pieces with disjoint interiors.
Equivalent to triangulation().convexPartition(), and the polygon has the same precondition it does: simple and non-degenerate. The pieces' union is the polygon and their interiors are pairwise disjoint, so anything additive over a decomposition — an area, a sweep, a Minkowski sum — may be summed over them. There are at most four times as many as the fewest possible; see Triangulation::convexPartition for why that is all one should want.
A convex polygon comes back as a single piece.
|
inlinenodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
inlinenodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
inlineconstexpr |
Returns a segment realizing the diameter (the farthest vertex pair).
The farthest pair of vertices of a simple polygon lies on its convex hull, so this builds a Convex from the polygon vertices and returns that hull's Convex::diameter(). Distances are compared exactly via squared length.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherConvex & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherHalfplane & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
A half-plane is the one-constraint half-plane intersection, and is handled as one: see difference(const OtherIntersection&) const.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherIntersection & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
A half-plane intersection may be unbounded, which stops it being a regularizedUnion operand but not a subtrahend: A ∖ B is bounded whenever A is, however far B reaches, so a PolygonSet can hold it. See PolygonWithHoles::difference(const OtherIntersection&) const for the clip that bounds it and for the rest of the contract.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherPolygon< PointType_, TLabel > & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
The result is closure(A° ∖ B): the part of this polygon with area that survives the removal, as a set of regions with pairwise disjoint interiors whose union is the difference. Lower-dimensional leftovers — a stretch of the boundary that other touches without covering, an isolated contact point — are dropped, which is the usual convention for boolean operations on solids and what makes the result a set of regions.
This is the construction PolygonWithHoles exists for: removing a polygon from the middle of another one leaves a hole, which no other shape in the library can express. Unlike intersection(const OtherPolygon&) const, which never needs one, this is where the nesting matters.
The pieces are not nested: an island of this polygon stranded inside a hole of the result comes back as a region of its own.
Complexity: O(m²) for m boundary edges, then a constrained triangulation over the arrangement of both boundaries.
| ResultNumber | The number type for the result. |
| other | The shape to remove. |
ResultNumber is, and converted only at the end. So an integral result type is exact whenever the boundaries cross at integral points, and truncates only where they genuinely do not. | PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherRectangle & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherRegion & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherSet & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
A difference is not symmetric, so this pair stays here rather than going to the higher-ranked set the way regularizedUnion(const OtherSet&) const does. It costs no more for it: the set goes into the one arrangement whole, exactly as it would have on the other side. See difference(const OtherPolygon&) const for the contract.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::difference | ( | const OtherTriangle & | other | ) | const |
|
nodiscard |
Returns the regularized set difference of the two shapes (A ∖ B).
|
inlinenodiscard |
Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper's own difference.
A difference is not symmetric, so unlike regularizedUnion this cannot be handed to other as it stands. It wraps this shape instead and lets the wrapper visit both sides, which throws if the pair is unsupported — here, whenever other turns out to hold anything without area, or a Disk. An unbounded alternative is fine on this side, the result being contained in this shape either way. See difference(const OtherPolygon&) const for the contract.
The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
inlinenodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
Forwards to the other shape's implementation so that each unordered pair needs distanceL1 defined only once, on the higher-ranked shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
|
inlinenodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
inlinenodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
Forwards to the other shape's implementation so that each unordered pair needs distanceLInf defined only once, on the higher-ranked shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
|
inlinenodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.
|
inlineconstexpr |
Returns the edges of the polygon.
|
inlineconstexpr |
Returns an iterator to the first unoriented edge.
|
inlineconstexpr |
Returns an iterator past the last unoriented edge.
|
inlineconstexpr |
|
inlinenodiscardconstexpr |
Returns whether the polygon is the empty set of points.
A polygon with no vertices covers nothing, which is the state of a default-constructed one and of every polygon-valued result that comes back empty. It behaves as EmptyShape: every predicate reads it as the empty set.
Complexity: O(1).
|
inlineconstexpr |
Returns a constant iterator past the last vertex.
|
constexpr |
Computes the floating-point bounding box of the polygon.
| ResultNumber | The floating-point type for the result. |
|
inlineconstexpr |
Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end. Useful for iterating polygon edges where the last edge wraps around.
|
inlinenodiscardconstexpr |
Returns the point the polygon collapses to, if it does.
Complexity: O(n), returning at the first differing vertex.
|
inlinenodiscardconstexpr |
Returns the segment the polygon collapses to, if it does.
Complexity: O(n).
|
nodiscardconstexpr |
Returns the kernel: the set of points that see the whole polygon.
Returns the kernel: the set of points that see the whole polygon.
A point p of the polygon belongs to the kernel when the segment pq stays inside the polygon for every point q of it. For a simple polygon the kernel is exactly the intersection of the closed half-planes bounded by the edge lines and lying on the interior side, hence convex — that intersection is what is returned.
The answer is only meaningful for a simple polygon (isSimple); as elsewhere in the library, a self-intersecting boundary is outside the contract. Degenerate polygons are handled: one collapsed to a point or a segment is its own kernel. The empty polygon (empty) and an undefined one (isUndefined) yield std::nullopt.
Complexity: O(n log n) for n vertices.
A point p of the polygon belongs to the kernel when the segment pq stays inside the polygon for every point q of it. For a simple polygon the kernel is exactly the intersection of the closed half-planes bounded by the edge lines and lying on the interior side, hence convex — that intersection is what is returned.
The answer is only meaningful for a simple polygon (isSimple); as elsewhere in the library, a self-intersecting boundary is outside the contract. Degenerate polygons are handled: one collapsed to a point or a segment is its own kernel. The empty polygon (empty) and an undefined one (isUndefined) yield std::nullopt.
Complexity: O(n log n) for n vertices.
Defined here because the result type must be complete: the polygon's vertices are canonically counterclockwise, so the interior lies to the left of every boundary edge and the kernel is built by inserting the half-plane of each edge in turn. Repeated consecutive vertices contribute no edge line and are skipped; collinear ones give a redundant constraint that HalfplaneIntersection::insert discards.
Defined here because the result type must be complete: the polygon's vertices are canonically counterclockwise, so the interior lies to the left of every boundary edge and the kernel is built by inserting the half-plane of each edge in turn. Repeated consecutive vertices contribute no edge line and are skipped; collinear ones give a redundant constraint that HalfplaneIntersection::insert discards.
|
inlineconstexpr |
Returns the smallest index i with (*this)[i] == point, or -1 if point is not a vertex.
Complexity: O(n) for n vertices (linear scan, since a simple polygon has no monotone structure to binary-search).
| point | The vertex to locate. |
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Complexity: O((n + m) log n) for n and m vertices.
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
True iff the point is contained but lies on no edge. A polygon with fewer than three vertices has empty interior, so the result is always false.
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Like contains(const Polygon&), this reduces to an edge-by-edge check, which is exact for simple polygons (no holes).
Complexity: O((n + m) log n) for n and m vertices.
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Complexity: O(n log n) for n vertices.
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Requires both endpoints strictly inside and no contact with the boundary, so a segment cannot dip out through a reflex notch and return.
Complexity: O(n) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
constexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Complexity: O(n log n) for n vertices.
|
constexpr |
Tests whether this shape's interior contains the segment's interior.
Every point of the open segment must lie strictly inside the polygon; either endpoint may lie on the polygon boundary. A degenerate segment is accepted exactly when its sole point is contained.
Complexity: O(n) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
nodiscardconstexpr |
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n^2) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
nodiscardconstexpr |
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n^2) for n vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n^2) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Forwards to the other shape's implementation so that each unordered pair needs interiorsIntersect defined only once, on the higher-ranked shape.
|
constexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
nodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
inlinenodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
|
nodiscardconstexpr |
Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments.
Same contract as intersection(const OtherPolyline&) const: Polygon outranks MonotoneChain and owns the pair. The chain is viewed as a Polyline (its lexicographic vertex order is a valid traversal) and clipped against the polygon.
| ResultNumber | Number type of the returned coordinates. |
| OtherChain | Type of the monotone chain. |
| other | Monotone chain to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Forwards to the intersection(const Polygon&) overload via the convex polygon's Convex::asPolygon representation.
| ResultNumber | The number type for the result. |
| OtherConvex | The convex polygon type. |
| other | The convex polygon to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
The boundary of the intersection region P ∩ H is (∂P ∩ H) ∪ (∂H ∩ P), so the method clips every polygon edge to the closed half-plane and clips the half-plane's boundary line to the polygon (via intersection(const Line&)), collecting the pieces into a deduplicated set. They are assembled exactly as in intersection(const Polygon&) – a graph whose nodes have degree at most two (asserted) – into isolated Point components, Segment components, and Polygon components, returned in no particular order. Unlike the polygon overload the 1D pieces are Segment rather than Polyline, because every 1D part of the intersection lies on the half-plane's straight boundary and so is collinear.
Complexity: O(n log n) for n vertices.
| ResultNumber | The number type for the result. |
| OtherPoint | The point type of the half-plane. |
| other | The half-plane to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Since a polygon is bounded, the intersection of its closed region with an infinite line is a bounded set of disjoint pieces: each is either a Point (an isolated boundary touch) or a Segment (a maximal chord), returned in order along the line. An empty vector means no intersection.
Uses the same exact, division-free ray-parity sweep as intersection(const Segment&), but without clipping to a finite range.
Complexity: O(n log n) for n vertices.
| ResultNumber | The number type for the result. |
| OtherPoint | The point type of the line. |
| other | The line to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Same as the Line overload, ignoring orientation.
Complexity: O(n log n) for n vertices.
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Same as the Segment overload, ignoring orientation.
Complexity: O(n log n) for n vertices.
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
The boundary of the intersection region A ∩ B is exactly (∂A ∩ B) ∪ (∂B ∩ A), so the method clips every edge of each polygon against the other (via intersection(const Segment&)) and collects the resulting boundary pieces into a deduplicated set of points and segments. The segments are assembled into a graph whose nodes are endpoints; in a non-degenerate configuration every node has degree at most two (asserted), so each connected component is an isolated node, a simple path, or a simple cycle. These become a Point, a Polyline, and a Polygon respectively, returned in no particular order.
Complexity: O(n m log(n + m)) for polygons with n and m vertices.
| ResultNumber | The number type for the result. |
| OtherPoint | The point type of the other polygon. |
| other | The other polygon to intersect with. |
|
nodiscardconstexpr |
Returns the intersection with an open polyline (A ∩ B), a sequence of points and segments.
A polyline is 1-dimensional, so the intersection with this polygon's region is a set of points and segments. Polygon owns this pair (it outranks Polyline); the computation is the polyline clipped against the polygon, delegated to Polyline::polygonIntersection. The pieces carry the polyline's label, matching polyline.intersection(polygon).
| ResultNumber | Number type of the returned coordinates. |
| OtherPolyline | Type of the polyline. |
| other | Polyline to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
A ray is its supporting line restricted to the half starting at the source, so the result is the disjoint pieces of that half inside the closed polygon: each is either a Point (an isolated boundary touch) or a Segment (a maximal chord), returned in order from the source outward. An empty vector means no intersection.
Uses the same exact, division-free ray-parity sweep as intersection(const Line&), clipped to the ray's half-line.
Complexity: O(n log n) for n vertices.
| ResultNumber | The number type for the result. |
| OtherPoint | The point type of the ray. |
| other | The ray to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Forwards to the intersection(const Convex&) overload via the rectangle's Rectangle::asConvex representation.
| ResultNumber | The number type for the result. |
| OtherRectangle | The rectangle type. |
| other | The rectangle to intersect with. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Unlike Convex::intersection, a simple polygon need not be convex, so the intersection of its closed region with a segment can be several disjoint pieces. The pieces are returned in order along the segment (from its min() endpoint to its max() endpoint); each piece is either a Point (an isolated boundary touch) or a Segment (a maximal overlap with the closed region). An empty vector means no intersection.
The supporting line is split at every boundary crossing and each cell is classified by exact (division-free) ray parity, so the result is correct for reflex polygons where both endpoints may lie inside yet the segment dips out through a notch.
Complexity: O(n log n) for n vertices.
| ResultNumber | The number type for the result. |
| OtherPoint | The point type of the segment. |
| other | The segment to intersect with. |
|
inlinenodiscard |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Forwards to the other shape's implementation so that each unordered pair needs intersection defined only once, on the higher-ranked shape. The result is then the higher-ranked shape's: intersecting with a PolygonWithHoles gives regions, not the component vector the polygon-polygon overload returns.
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Forwards to the intersection(const Convex&) overload via the triangle's Triangle::asConvex representation.
| ResultNumber | The number type for the result. |
| OtherTriangle | The triangle type. |
| other | The triangle to intersect with. |
|
inlinenodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersection.
An intersection is symmetric, so this just calls other's own intersection, which visits its wrapped alternative and throws if the pair is unsupported.
The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.
other holds is not known until run time, so neither is the result's.
|
inlinenodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
nodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Decomposes both boundaries into monotone chains via boundariesIntersect; when the boundaries are disjoint a single point-in-polygon test each way settles containment.
|
nodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n) for n vertices.
|
inlinenodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Forwards to the other shape's implementation so that each unordered pair needs intersects defined only once, on the higher-ranked shape.
|
constexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Complexity: O(n m) for polygons with n and m vertices.
|
nodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
inlinenodiscardconstexpr |
Tests whether the polygon is convex.
True when every turn along the boundary has the same orientation, i.e. there is no reflex vertex (collinear vertices are permitted). The answer is only meaningful for a simple polygon (isSimple); as elsewhere in the library, a self-intersecting boundary is outside the contract. A polygon with fewer than three vertices is reported as non-convex.
Complexity: O(n).
|
inlineconstexpr |
Checks if the polygon is degenerate (has zero area).
The empty polygon has no area either, so it is degenerate.
Collinear vertices are what a well-defined polygon without area looks like, and isPoint / isSegment decide that exactly whatever the coordinates. Only isUndefined — a boundary that retraces itself — has no area without being collinear, and it is the one branch that needs the shoelace sum, taken in the promoted type. twiceArea() == 0 would instead narrow that sum to NumberType, where the area of an ordinary polygon past the coordinate range wraps to zero.
|
inlinenodiscardconstexpr |
Checks whether the polygon covers exactly one point.
Complexity: O(n), returning at the first differing vertex.
|
inlinenodiscardconstexpr |
Checks whether the polygon covers exactly one segment of positive length.
True when the vertices are collinear but not all equal. The boundary is a closed walk, so collinear vertices make it cover the single segment spanning them.
Complexity: O(n), returning at the first non-collinear vertex.
|
nodiscard |
Tests whether the polygon is simple (its boundary does not touch or cross itself).
Tests whether the polygon boundary is simple.
Uses a brute-force pairwise edge test in O(n^2) for few vertices (n <= 8) or floating-point coordinates, and the Bentley-Ottmann sweep (O(n log n)) for larger exact (integer or rational) polygons. A polygon with fewer than three vertices, or a zero-length edge (a repeated consecutive vertex), is not simple.
| Rational | Exact rational type used by the sweep for large polygons. |
Integer and rational coordinates go to the exact sweep line, which needs them; floating-point ones go to the bounding-box sweep of detail::visitXYSweepPairs, which reaches the same verdict through the same predicates as the pairwise scan while testing only the pairs that can possibly meet. A polygon small enough for the pairwise scan to win takes it directly.
| Rational | Exact rational type used internally by the sweep line. |
|
inlinenodiscardconstexpr |
Tests whether the polygon is star-shaped.
True when some point of the polygon sees all of it, i.e. when the kernel (getStarShapedKernel) is non-empty. Every convex polygon is star-shaped; the converse does not hold.
Complexity: O(n log n) for n vertices.
|
inlinenodiscardconstexpr |
Checks whether the polygon is degenerate without covering a point or a segment.
Zero area does not imply collinear vertices: a self-overlapping boundary whose signed area cancels out (or one that retraces a non-straight path) is degenerate yet covers more than a segment. Such a polygon is the only undefined case; the empty polygon is the well-defined empty set, so use empty for it.
Complexity: O(n).
|
inlineconstexpr |
Returns the polygon label.
The label is mutable even through a const polygon: it is metadata that does not participate in equality, hashing, or geometric predicates.
|
nodiscard |
Returns the integer points the polygon contains.
The boundary included: a point on an edge is a point of the shape. The boundary answers for its own points, edge by edge as segments, and a sweep over the columns of the bounding box answers for the rest, so the cost is one pass over the edges plus one point per point reported.
| ResultNumber | Integer coordinate type of the points: the shape's own coordinate type when that is a signed integer, the integer a pgl::Rational is built on, and int64_t for anything else. |
| std::logic_error | If a coordinate is not finite, or a lattice point of the shape does not fit ResultNumber. |
| std::length_error | If there are more of them than a vector holds. |
|
nodiscard |
Returns the regularized Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B), as a set of regions.
The pairs MinkowskiSummableConcept turns away, which for this receiver is every bounded operand: the erosion of a shape that is not convex is no more convex than it was, and it is not even connected – a dumbbell eroded by anything wider than its handle is two regions, for operands that are in no way degenerate. That is why this returns a PolygonSet where minkowskiSum returns one PolygonWithHoles, and the difference is structural rather than a missing guarantee.
The result is regularized, closure((A ⊖ B)°), as the sum and the boolean operations are: an erosion produces thin material readily – a corridor exactly as wide as the operand erodes to a curve – and a set of regions holds none of it. A receiver with no area erodes to the empty set for the same reason.
A convex receiver is answered by its own constraints in O(a·b); everything else pays for a complement, a sum and a difference. See implementation/minkowskierosion.hpp for both constructions and their cost.
| ResultNumber | Coordinate type of the result. |
| OtherShape | Type of the shape to erode by. |
| other | Shape to erode by. |
| std::logic_error | when other covers no point: that erosion is the whole plane, which no set of bounded regions represents. |
|
nodiscardconstexpr |
Returns the Minkowski erosion of this shape by another (A ⊖ B).
The erosion is the point set {x : x ⊕ B ⊆ A}, the translations of other that keep it inside this shape – equivalently ⋂ {A - b : b ∈ B}. It is the morphological dual of minkowskiSum and is defined for the same pairs, but it is not commutative.
Eroding by a Point is the translation by its negation, so it returns this shape's own type; the other pairs come back as the convex region they are, a HalfplaneIntersection, which holds a lower-dimensional erosion and the empty one as readily as a two-dimensional one. A polygon eroded by a bounded operand needs a PolygonSet, since an erosion can disconnect what it shrinks.
Eroding by a shape that covers no point is the whole plane, which a HalfplaneIntersection returns and the tighter result types cannot.
| OtherShape | Type of the shape to erode by. |
| other | Shape to erode by. |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherChain & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
A MonotoneChain summand is a polyline that happens to be sorted, and it sums here exactly as one: its monotonicity is what makes MonotoneChain::minkowskiSum(const OtherConvex&) const one polygon, and a non-convex receiver takes that away again — this polygon's own concavity can strand a cavity whatever the chain does. So the chain contributes its edges and the answer is one region, which may have holes.
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherConvex & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherOriented & | other | ) | const |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherPolygon< PointType_, TLabel > & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
The sum is {p + q : p ∈ A, q ∈ B}, regularized to closure((A ⊕ B)°) and returned as a region with holes. A non-convex operand is what makes that necessary: sliding a shape around the inside of a U sweeps out a region whose boundary closes over a hole, and no other shape in the library can say so. This is the gap PolygonWithHoles was proposed to close.
This polygon must be nondegenerate, and that is what buys the single region: a nondegenerate polygon is the closure of its connected interior, so A ⊕ B covers ⋃_{b ∈ B} (A° + b), which is connected and open for any connected B and whose closure is the sum. A degenerate polygon — one with no area — is not on this contract; the sum can then fall into several pieces, of which one comes back. An empty or wholly flat regularized sum is the empty region.
Distinguish this from minkowskiSum(const OtherShape&) const, which sums a bounded convex operand and returns a single Convex (or a Rectangle, or a translation of this polygon by a Point). The two never overlap: the pairs that fit in one shape are exactly the pairs MinkowskiSummableConcept accepts, and this overload set takes the rest.
Complexity: one convex merge per pair of triangles of the two operands' triangulations, then a constrained triangulation over the arrangement of all of them.
| ResultNumber | The number type for the result. |
| other | The shape to sum with. |
ResultNumber only at the end. | PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherPolyline & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
A Polyline summand has no area, but it sweeps this polygon along itself all the same, so the sum is a region like every other one here. This is the mirror of Polyline::minkowskiSum(const OtherPolygon&) const and gives the same single-region answer: which operand is written first never decides which sum answers.
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherRectangle & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherRegion & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherSegment & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
An orientation is not part of a point set, so this is the sum with the underlying segment, vertex for vertex.
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
The thinnest summand that still needs a region. A segment has no area, but sliding this polygon along one sweeps the band between the polygon and its translate by the segment's vector, and that band closes over a cavity for the same reason a wider summand's does: a C whose opening is no wider than the vector is plugged by the sweep of its own arms. The summand is a single convex piece, so this is the cheapest of these sums — one convex merge per triangle of the triangulated domain.
Distinguish it from segment + segment, which stays a single Convex: two bounded convex operands never need a region, and it is the receiver's concavity, not the summand's thinness, that brings one in. As everywhere here the result is regularized, so a summand that has collapsed to a point comes back empty rather than as a flat copy of this polygon.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherSet & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B), as a set of regions.
A PolygonSet operand is the one whose answer needs a set whatever the other operand is: its components are disjoint, and a sum small relative to the gaps between them leaves them so. The set outranks every shape here and owns the pair, so this is the mirror spelling of PolygonSet::minkowskiSum, and the same call.
|
nodiscardconstexpr |
Returns the Minkowski sum of this shape and another (A ⊕ B).
The sum is the point set {a + b : a ∈ A, b ∈ B}. Summing with a Point is a translation, so it returns this shape's own type; two bounded convex shapes sum to a Convex, or to a Rectangle when both are rectangles. See MinkowskiSummableConcept for the pairs a Minkowski sum is defined for.
| OtherShape | Type of the other shape. |
| other | Shape to sum with. |
| PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::minkowskiSum | ( | const OtherTriangle & | other | ) | const |
|
nodiscard |
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
|
inlineconstexpr |
Scales the polygon by the given scalar.
Complexity: O(n) for n vertices. Scaling by a negative factor flips the orientation, so the polygon is renormalized to stay canonical.
|
inlineconstexpr |
Translates the polygon by the given point.
Complexity: O(1).
|
inlineconstexpr |
Translates the polygon by the negation of the given point.
Complexity: O(1).
|
inlineconstexpr |
Divides the polygon by the given scalar.
Complexity: O(n) for n vertices.
|
inlineconstexpr |
Compares two polygons by their canonical vertex sequences.
|
inlineconstexpr |
Checks equality of two polygons.
|
inlineconstexpr |
Accesses a vertex by index.
| index | The index of the vertex. |
|
inlineconstexpr |
Returns the oriented edges of the polygon.
|
inlineconstexpr |
Returns an iterator to the first oriented edge.
|
inlineconstexpr |
Returns an iterator past the last oriented edge.
|
inlineconstexpr |
Lazy view counterpart of orientedEdges(); see edgesView().
|
nodiscardconstexpr |
Returns a point strictly inside the (simple) polygon.
Works for non-convex polygons. The lexicographically smallest vertex p0 (stored first in canonical form) is convex, so the triangle formed by p0 and its two boundary neighbours a, b lies locally inside the polygon. If no other vertex falls inside that triangle it is an ear and its interior point is returned; otherwise the lexicographically smallest vertex q inside the triangle yields a valid diagonal p0 q, and its midpoint is returned. Only meaningful for a simple polygon.
Complexity: O(n).
| ResultNumber | The number type for the result. |
|
nodiscardconstexpr |
Tests whether some point in this shape's relative interior lies in the strict interior of shape.
Uses pointInside as the witness. When integer truncation rounds that witness onto or outside the boundary, this shape and shape are scaled so the witness is exact, leaving the containment relation unchanged.
|
nodiscard |
Returns the reduced visibility graph of the polygon vertices.
The subgraph of visibilityGraph holding the edges a shortest path inside the polygon can bend along: those tangent to the boundary at both ends. An edge uv is tangent at u when the two sides meeting at u lie in one closed half-plane of the line uv, which is what lets a taut path bend there. Every side survives; among the diagonals only the bitangents between reflex corners do, so this is far sparser than visibilityGraph.
This graph alone does not answer shortest-path queries. It guarantees only the interior of a geodesic — an edge strictly inside a shortest path has the path bending at both ends, hence is tangent at both and survives. A path does not bend at its own endpoints, so its first and last hop need no tangency and may have been pruned; a convex corner keeps only its two sides, and a route starting there comes back forced along the boundary. To route between two points, add each joined to everything it sees, taken from visibilityGraph.
The answer is meaningful for a simple polygon. A degenerate polygon has every vertex collinear with every side, so the tangency test passes everywhere and the result matches visibilityGraph.
Complexity: as visibilityGraph, plus O(m) for m visibility edges.
|
inlinenodiscard |
Forwards a regularized intersection to the shape that owns it.
|
inlinenodiscard |
Re-dispatches a regularized intersection through a runtime shape.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::regularizedUnion | ( | const OtherConvex & | other | ) | const |
|
nodiscard |
Returns the regularized union of the two shapes (A ∪ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::regularizedUnion | ( | const OtherPolygon< PointType_, TLabel > & | other | ) | const |
|
nodiscard |
Returns the regularized union of the two shapes (A ∪ B).
The result is closure(A° ∪ B°), as a set of regions with pairwise disjoint interiors. It needs PolygonWithHoles for the same reason the difference does: two shapes that wrap round between them enclose a hole neither of them has, as a U united with the bar that caps it.
Operands meeting only along a stretch of boundary or at a single point fuse only where they have area in common to fuse through — an isolated contact point comes back as two pieces meeting there, since a region may not have a self-touching outer ring. Disjoint operands come back as two pieces.
Complexity: O(m²) for m boundary edges, then a constrained triangulation over the arrangement of both boundaries.
| ResultNumber | The number type for the result. |
| other | The shape to unite with. |
ResultNumber is, and converted only at the end. So an integral result type is exact whenever the boundaries cross at integral points, and truncates only where they genuinely do not. | PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::regularizedUnion | ( | const OtherRectangle & | other | ) | const |
|
nodiscard |
Returns the regularized union of the two shapes (A ∪ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::regularizedUnion | ( | const OtherRegion & | other | ) | const |
|
nodiscard |
Returns the regularized union of the two shapes (A ∪ B).
|
inlinenodiscard |
Returns the regularized union of the two shapes (A ∪ B).
A set of regions is the one PolygonalRegionConcept operand ranked above a polygon, and it states its operations over every operand at once, so this hands the pair back to it rather than restating it. A union is symmetric, so the order costs nothing — and going through the set is what puts every component into one arrangement instead of folding the polygon over them one at a time. See regularizedUnion(const OtherPolygon&) const for the contract.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::regularizedUnion | ( | const OtherTriangle & | other | ) | const |
|
nodiscard |
Returns the regularized union of the two shapes (A ∪ B).
|
inlinenodiscard |
Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own regularizedUnion.
A union is symmetric, so this just calls other's own regularizedUnion, which visits its wrapped alternative and throws if the pair is unsupported — here, whenever other turns out to hold anything but a bounded polygonal region. See Polygon::regularizedUnion for the contract.
The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.
|
nodiscard |
The part of the polygon visible from query, regularized.
The visibility polygon: every point reachable from query by a segment staying inside. Being star-shaped about query it is simply connected, so one Polygon holds it.
Regularized means the closure of the interior, which drops what grazing sight would otherwise add: a sightline running along the boundary, or straight through a vertex into a part beyond that has no area, contributes a one-dimensional spike to the visible set and none to this. What comes back always bounds area.
Its vertices are the polygon's own together with the window ends where a sightline past a reflex corner lands on a farther edge. Those are ray-edge intersections and need division, so the result type is requested explicitly, as everywhere in the library. A query on the boundary is a vertex of the result.
The answer is meaningful for a simple polygon; a degenerate one bounds no area and gives an empty polygon.
| ResultNumber | Coordinate type of the result (default: division_result_t of the polygon's own). |
| query | Point to look from. |
query lies outside the polygon.
|
constexpr |
Rotates the polygon by 90k degrees around the origin in place.
| k | Number of 90-degree CCW rotations (may be negative). |
|
nodiscardconstexpr |
Returns the polygon rotated by 90k degrees around the origin.
| k | Number of 90-degree CCW rotations (may be negative). |
|
nodiscardconstexpr |
Tests whether another shape defines exactly the same point set.
|
constexpr |
|
nodiscardconstexpr |
Returns the polygon with its x-coordinates divided by a divisor.
|
constexpr |
|
nodiscardconstexpr |
Returns the polygon with its y-coordinates divided by a divisor.
|
constexpr |
Divides the polygon's x-coordinates by a divisor in place.
|
constexpr |
Divides the polygon's y-coordinates by a divisor in place.
|
constexpr |
|
nodiscardconstexpr |
Returns the polygon with its x-coordinates multiplied by a factor.
|
constexpr |
|
nodiscardconstexpr |
Returns the polygon with its y-coordinates multiplied by a factor.
|
constexpr |
Multiplies the polygon's x-coordinates by a factor in place.
|
constexpr |
Multiplies the polygon's y-coordinates by a factor in place.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
The chain is an arc whose arc order is its lexicographic vertex order, so removing this polygon cuts the chain exactly when the chain has ordered points a < b < c with b inside the polygon and a, c outside (an edge carrying all three is a separated edge; otherwise a and c straddle a covered vertex or edge).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
constexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
constexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
constexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Set semantics: the polyline's free pieces may reconnect through its own self-intersections, so they are joined geometrically rather than in traversal order (see detail::separates1DSet).
|
constexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Like the segment overload, but a ray has a single finite end (its source); its far end runs to infinity, always outside the bounded polygon, so only the source can lie inside.
Complexity: O(n) for n vertices.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscard |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
The region is settled by the cell engine of implementation/separates.hpp; see the notes on pgl::PolygonWithHoles::separates for what a region admits that a simply connected target does not.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
constexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
True iff some boundary edge cuts transversally through the segment's interior while the segment does not lie on the boundary, so the polygon's body interrupts the segment.
Complexity: O(n) for n vertices.
|
nodiscard |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
A set of regions is the one target that may already be in several pieces before anything is removed, so this neither folds over its components nor answers false for a remover that misses it. See implementation/separates.hpp.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
inlineconstexpr |
Returns the number of vertices in the polygon.
|
nodiscard |
Returns the squared Euclidean distance to a disk.
Zero when the polygon's closed region intersects the disk; otherwise the squared exterior gap. Reports in detail::floating_result_t<ResultNumber>: the gap to a circle is generally irrational, so a floating-point ResultNumber is honoured as asked and any other request falls back to double.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
inlinenodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Forwards to the other shape's implementation so that each unordered pair needs squaredDistance defined only once, on the higher-ranked shape.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Zero when the polygon's closed region intersects the other shape; otherwise the smallest squared distance between the two shapes. When they are disjoint the polygon's closest point lies on its boundary, so the result is the minimum over the boundary edges of the edge-to-shape squared distance.
Complexity: O(n) edge queries for n vertices, each against the other shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value. | PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::symmetricDifference | ( | const OtherConvex & | other | ) | const |
|
nodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::symmetricDifference | ( | const OtherPolygon< PointType_, TLabel > & | other | ) | const |
|
nodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
The result is closure((A° ∖ B) ∪ (B° ∖ A)), as a set of regions with pairwise disjoint interiors: the part covered by exactly one of the two operands. It is the union of the two differences, and inherits holes from both.
Complexity: O(m²) for m boundary edges, then a constrained triangulation over the arrangement of both boundaries.
| ResultNumber | The number type for the result. |
| other | The other shape. |
ResultNumber is, and converted only at the end. | PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::symmetricDifference | ( | const OtherRectangle & | other | ) | const |
|
nodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::symmetricDifference | ( | const OtherRegion & | other | ) | const |
|
nodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
|
inlinenodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
A set of regions is the one PolygonalRegionConcept operand ranked above a polygon, and it states its operations over every operand at once, so this hands the pair back to it rather than restating it, exactly as regularizedUnion(const OtherSet&) const does. See symmetricDifference(const OtherPolygon&) const for the contract.
| PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polygon< PointType_, TLabel >::symmetricDifference | ( | const OtherTriangle & | other | ) | const |
|
nodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B).
|
inlinenodiscard |
Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wrapper's own symmetricDifference.
A symmetric difference is symmetric, so this just calls other's own, which visits its wrapped alternative and throws if the pair is unsupported. See symmetricDifference(const OtherPolygon&) const for the contract.
The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.
| auto pgl::Polygon< PointType_, TLabel >::triangulation | ( | ) | const |
Builds the constrained Delaunay triangulation of this polygon.
Equivalent to Triangulation(*this). The polygon must be simple (non-self-intersecting) and non-degenerate.
| auto pgl::Polygon< PointType_, TLabel >::triangulation | ( | const PointRange & | points, |
| const SegmentRange & | segments ) const |
Builds the constrained Delaunay triangulation of this polygon with the given interior vertices and constraint segments.
Equivalent to Triangulation(*this, points, segments). The polygon must be simple (non-self-intersecting) and non-degenerate, and the points and segments are assumed to lie inside it (not checked).
| auto pgl::Polygon< PointType_, TLabel >::triangulation | ( | const SegmentRange & | segments | ) | const |
Builds the constrained Delaunay triangulation of this polygon with the given interior constraint segments.
Equivalent to Triangulation(*this, segments). The polygon must be simple (non-self-intersecting) and non-degenerate, and the segments are assumed to lie inside it (not checked).
|
inlineconstexpr |
Computes twice the (unsigned) area of the polygon via the shoelace formula.
| ResultNumber | Type the sum is accumulated in, NumberType by default. The shoelace terms are products of coordinates, so a polygon whose area leaves the coordinate range wraps; pass a wider type to measure such a polygon. |
|
constexpr |
Makes the polygon simple in place by uncrossing its boundary.
Repeatedly removes self-intersections until the boundary is a simple closed curve. At runtime, every round indexes the current boundary edges in an interval tree, greedily selects an edge-disjoint batch of crossing pairs, applies all of their flips, and rebuilds the tree for the changed boundary. Two kinds of moves are applied:
Because every move either shortens the perimeter at a fixed vertex count or drops a vertex, the process terminates, and on return the polygon is simple (isSimple). The surviving vertices are a subset of the originals with their positions unchanged, then renormalized to canonical form. A polygon with fewer than three vertices is left untouched.
Runtime candidate searches are output-sensitive after an O(n log n) tree build per batch. A batch can still take O(n^2) when many projected intervals overlap or many vector sub-paths are reversed, and the number of batches has no polynomial bound in n. Constant evaluation uses an O(n^2) pairwise scan for each move instead of the runtime index.
|
inlineconstexpr |
Returns the vertices of the polygon (translation applied).
|
inlineconstexpr |
Computes the centroid of the vertex set (the average of the vertices).
| ResultNumber | The number type for the result. |
|
inlineconstexpr |
Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.
Same vertex sequence as vertices(), with no heap allocation. The polygon is itself a vertex range, so this is just begin() and end() packaged as a view for callers that take one.
|
nodiscard |
Returns the visibility graph of the polygon vertices.
Two vertices are adjacent exactly when the closed segment joining them is contained in the closed polygon. Consequently boundary edges, and diagonals that touch or overlap the boundary without leaving the polygon, are visible.
The answer is meaningful for a simple polygon. Degenerate polygons are handled as their represented point set: an empty polygon gives an empty graph, while a polygon collapsed to a point or segment connects every pair of distinct contained vertices.
Triangulates the polygon and runs one cone-clipped traversal of the mesh per vertex — triangular expansion — whose cost is proportional to the part of the polygon that vertex actually sees. A convex polygon skips the triangulation: every segment between its vertices is inside it, so the answer is the complete graph. See Triangulation::visibilityGraph.
Complexity: O(n·t + m) time for n vertices, m visibility edges and t triangles seen per vertex, plus O(m) space for the returned graph.
|
nodiscard |
The polygon vertices visible from query.
Same convention as visibilityGraph, for a point that need not be a vertex: a vertex v is reported when the closed segment query–v is contained in the closed polygon, grazing included. This is what joins a query point to reducedVisibilityGraph, which by itself holds only the edges a shortest path can bend along.
The answer is meaningful for a simple polygon.
| query | Point to look from; outside the polygon nothing is visible. |
query starting from the lexicographically smallest, as sortAround orders them. Empty when query lies outside the polygon.