Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
pgl::Polyline< PointType_, TLabel > Struct Template Reference

Open polygonal chain stored in traversal order; may self-intersect. More...

#include <polyline.hpp>

Inheritance diagram for pgl::Polyline< PointType_, TLabel >:
[legend]

Classes

class  BoundaryIterator
 Forward iterator over the (optionally oriented) polyline 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 Polyline ()=default
 Creates a polyline 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 Polyline (Range &&points)
 Creates a polyline from a range of points.
constexpr Polyline (std::initializer_list< NumberType > coords)
 Creates a polyline from a flat list of coordinates.
template<PointConcept OtherPointType, class OtherLabelType>
requires std::constructible_from<PointType, const OtherPointType&>
constexpr Polyline (const Polyline< OtherPointType, OtherLabelType > &other)
 Converts a polyline with compatible vertex type.
template<class A = LabelType>
requires (detail::has_label_v<A>)
constexpr A & label () const
 Returns the polyline label.
constexpr const PointType operator[] (std::size_t index) const
 Accesses a vertex by index (in traversal order).
constexpr PointType get (std::ptrdiff_t index) const
 Accesses a vertex by index modulo the vertex count.
template<PointConcept OtherPoint>
constexpr void set (std::size_t index, const OtherPoint &point)
 Replaces the vertex at the given index.
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.
template<PointConcept OtherPoint>
constexpr void insert (std::size_t index, const OtherPoint &point)
 Inserts a vertex at the given index, shifting the later vertices back.
template<std::ranges::input_range Range>
requires (!detail::is_point_v<std::remove_cvref_t<Range>>) && std::convertible_to<std::ranges::range_value_t<Range>, PointType>
constexpr void insert (std::size_t index, Range &&points)
 Inserts a range of vertices at the given index, shifting the later vertices back.
template<PointConcept OtherPoint>
constexpr void pushBack (const OtherPoint &point)
 Appends a vertex, extending the polyline by one edge.
template<std::ranges::input_range Range>
requires (!detail::is_point_v<std::remove_cvref_t<Range>>) && std::convertible_to<std::ranges::range_value_t<Range>, PointType>
constexpr void pushBack (Range &&points)
 Appends a range of vertices in order.
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 Polyline &other) const
 Compares two polylines by their canonical vertex sequences.
constexpr bool operator== (const Polyline &other) const
 Checks equality of two polylines.
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 polyline.
constexpr bool empty () const
 Checks whether the polyline has no vertex.
constexpr bool isDegenerate () const
 Checks if the polyline is degenerate (all vertices are equal, so it covers at most a single point).
constexpr bool isPoint () const
 Checks whether the polyline covers exactly one point.
constexpr std::optional< PointTypegetIfPoint () const
 Returns the point the polyline collapses to, if it does.
constexpr bool isSegment () const
 Checks whether the polyline covers exactly one segment of positive length.
constexpr std::optional< BoundaryType< false > > getIfSegment () const
 Returns the segment the polyline collapses to, if it does.
constexpr bool isUndefined () const
 Checks whether the polyline is degenerate without covering a point or a segment.
template<class Rational = pgl::Rational<pgl::BigInt>>
bool isSimple () const
 Tests whether the polyline is simple (it does not touch or cross itself).
constexpr Segment< PointTypediameter () const
 Returns a segment realizing the diameter (the farthest vertex pair).
constexpr Convex< PointTypeconvexHull () const
 Returns the convex hull of the polyline's vertices.
constexpr const Rectangle< PointType > & bbox () const
 Computes the bounding box of the polyline.
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 polyline contains.
template<std::floating_point ResultNumber = double>
constexpr Rectangle< Point< ResultNumber > > fbox () const
 Computes the floating-point bounding box of the polyline.
constexpr std::vector< PointTypevertices () const
 Returns the vertices of the polyline (translation applied).
constexpr std::vector< Segment< PointType > > edges () const
 Returns the edges of the polyline.
constexpr std::vector< OrientedSegment< PointType > > orientedEdges () const
 Returns the oriented edges of the polyline, each directed from vertex i to vertex i + 1 in traversal order.
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.
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<DiskConcept OtherDisk>
constexpr bool contains (const OtherDisk &other) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<MonotoneChainConcept OtherChain>
constexpr bool contains (const OtherChain &other) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<PolylineConcept OtherPolyline>
constexpr bool contains (const OtherPolyline &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<PointConcept OtherPoint>
constexpr bool contains (const Shape< OtherPoint > &other) const
 Tests whether this shape contains the other shape (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 &) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool boundaryContains (const OtherOrientedLine &) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<RayConcept OtherRay>
constexpr bool boundaryContains (const OtherRay &) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<HalfplaneConcept OtherHalfplane>
constexpr bool boundaryContains (const OtherHalfplane &) 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<MonotoneChainConcept OtherChain>
constexpr bool boundaryContains (const OtherChain &other) const
 Tests whether this shape's boundary 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<class EmptyPoint>
constexpr bool boundaryContains (const EmptyShape< EmptyPoint > &) 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<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<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<TriangleConcept OtherTriangle>
constexpr bool interiorContains (const OtherTriangle &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<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<DiskConcept OtherDisk>
constexpr bool interiorContains (const OtherDisk &other) const
 Tests whether this shape's interior contains the other shape (A∖∂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<PolylineConcept OtherPolyline>
constexpr bool interiorContains (const OtherPolyline &other) const
 Tests whether this shape's interior contains the other shape (A∖∂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 Shape< OtherPoint > &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
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<DiskConcept OtherDisk>
constexpr bool intersects (const OtherDisk &other) const
 Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
template<MonotoneChainConcept OtherChain>
constexpr bool intersects (const OtherChain &other) const
 Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
template<PolylineConcept OtherPolyline>
constexpr bool intersects (const OtherPolyline &other) const
 Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
template<class EmptyPoint>
constexpr bool intersects (const EmptyShape< EmptyPoint > &) const
 Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
template<PointConcept OtherPoint>
constexpr bool intersects (const Shape< OtherPoint > &other) const
 Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
constexpr bool intersects (const OtherShape &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 shapes intersect (A° ∩ B° ≠ ∅).
template<SegmentConcept OtherSegment>
constexpr bool interiorsIntersect (const OtherSegment &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<OrientedSegmentConcept OtherOrientedSegment>
constexpr bool interiorsIntersect (const OtherOrientedSegment &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<LineConcept OtherLine>
constexpr bool interiorsIntersect (const OtherLine &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool interiorsIntersect (const OtherOrientedLine &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<RayConcept OtherRay>
constexpr bool interiorsIntersect (const OtherRay &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<HalfplaneConcept OtherHalfplane>
constexpr bool interiorsIntersect (const OtherHalfplane &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<RectangleConcept OtherRectangle>
constexpr bool interiorsIntersect (const OtherRectangle &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<TriangleConcept OtherTriangle>
constexpr bool interiorsIntersect (const OtherTriangle &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<ConvexConcept OtherConvex>
constexpr bool interiorsIntersect (const OtherConvex &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<DiskConcept OtherDisk>
constexpr bool interiorsIntersect (const OtherDisk &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<MonotoneChainConcept OtherChain>
constexpr bool interiorsIntersect (const OtherChain &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<PolylineConcept OtherPolyline>
constexpr bool interiorsIntersect (const OtherPolyline &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<class EmptyPoint>
constexpr bool interiorsIntersect (const EmptyShape< EmptyPoint > &) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<PointConcept OtherPoint>
constexpr bool interiorsIntersect (const Shape< OtherPoint > &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
constexpr bool interiorsIntersect (const OtherShape &other) const
 Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
template<PointConcept OtherPoint>
constexpr bool separates (const OtherPoint &) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
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<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<RayConcept OtherRay>
constexpr bool separates (const OtherRay &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 separates (const OtherChain &other) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
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<class EmptyPoint>
constexpr bool separates (const EmptyShape< EmptyPoint > &) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
template<PointConcept OtherPoint>
constexpr bool separates (const Shape< OtherPoint > &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<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<RayConcept OtherRay>
constexpr bool crosses (const OtherRay &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<HalfplaneConcept OtherHalfplane>
constexpr bool crosses (const OtherHalfplane &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<RectangleConcept OtherRectangle>
constexpr bool crosses (const OtherRectangle &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<TriangleConcept OtherTriangle>
constexpr bool crosses (const OtherTriangle &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<DiskConcept OtherDisk>
constexpr bool crosses (const OtherDisk &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<ConvexConcept OtherConvex>
constexpr bool crosses (const OtherConvex &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
template<MonotoneChainConcept OtherChain>
constexpr bool crosses (const OtherChain &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
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 EmptyPoint>
constexpr bool crosses (const EmptyShape< EmptyPoint > &) 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<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
constexpr bool crosses (const OtherShape &other) const
 Tests whether the two shapes mutually separate each other (each disconnects the other).
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 with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
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 with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
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 with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
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 with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
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 with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
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 > > > > intersection (const OtherHalfplane &other) const
 Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherRectangle &other) const
 Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherTriangle &other) const
 Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherConvex &other) const
 Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherChain &other) const
 Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherPolyline &other) const
 Returns the intersection of the two polylines (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, class OtherArea>
requires (PolygonConcept<OtherArea> || PolygonWithHolesConcept<OtherArea>)
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > polygonIntersection (const OtherArea &other) const
 Returns the intersection with a polygon or a region (A ∩ B), a sequence of points and segments sorted by lexicographic order.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape&
o, const Polyline& self) { o.template intersection<ResultNumber>(self); })
constexpr auto intersection (const OtherShape &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
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>, 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>, 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>, PolylineConcept OtherPolyline>
constexpr auto squaredDistance (const OtherPolyline &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 = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& 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 = NumberType, BoundedPolygonalConcept OtherShape>
requires detail::ClosestPairConcept<Polyline<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<Polyline<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>, 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>, 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>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& 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 = double, PointConcept OtherPoint>
constexpr auto distanceL1 (const Shape< OtherPoint > &other) const
 Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceL1.
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>, MonotoneChainConcept OtherChain>
constexpr auto distanceLInf (const OtherChain &other) const
 Returns the Chebyshev (LInf) 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<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& 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 distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceLInf.
template<class ApproximateNumber = double>
ApproximateNumber length () const
 Computes the Euclidean length of the polyline (the sum of its edge lengths).
constexpr auto lengthL1 () const
 Computes the Manhattan (L1) length of the polyline.
constexpr auto lengthLInf () const
 Computes the Chebyshev (LInf) length of the polyline.
template<class ResultNumber = division_result_t<NumberType>>
constexpr Point< ResultNumber > pointInside () const
 Returns a point inside the polyline.
constexpr Polyline rotated90 (int k=1) const
 Returns the polyline rotated by 90k degrees around the origin.
constexpr void rotate90 (int k=1)
 Rotates the polyline by 90k degrees around the origin in place.
template<class OtherNumber>
constexpr Polyline scaledUpX (const OtherNumber scalar) const
 Returns the polyline with its x-coordinates multiplied by a factor.
template<class OtherNumber>
constexpr void scaleUpX (const OtherNumber scalar)
 Multiplies the polyline's x-coordinates by a factor in place.
template<class OtherNumber>
constexpr Polyline scaledUpY (const OtherNumber scalar) const
 Returns the polyline with its y-coordinates multiplied by a factor.
template<class OtherNumber>
constexpr void scaleUpY (const OtherNumber scalar)
 Multiplies the polyline's y-coordinates by a factor in place.
template<class OtherNumber>
constexpr Polyline scaledDownX (const OtherNumber scalar) const
 Returns the polyline with its x-coordinates divided by a divisor.
template<class OtherNumber>
constexpr void scaleDownX (const OtherNumber scalar)
 Divides the polyline's x-coordinates by a divisor in place.
template<class OtherNumber>
constexpr Polyline scaledDownY (const OtherNumber scalar) const
 Returns the polyline with its y-coordinates divided by a divisor.
template<class OtherNumber>
constexpr void scaleDownY (const OtherNumber scalar)
 Divides the polyline's y-coordinates by a divisor in place.
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
constexpr bool flippable (const OldSegment &oldEdge, const NewSegment &newEdge) const
 Tests whether oldEdge can be flipped to newEdge.
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
constexpr Polyline flipped (const OldSegment &oldEdge, const NewSegment &newEdge) const
 Returns the polyline with oldEdge flipped to newEdge.
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
constexpr void flip (const OldSegment &oldEdge, const NewSegment &newEdge)
 Flips oldEdge to newEdge in place.
template<class OtherShape>
requires MinkowskiSummableConcept<Polyline<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<Polyline<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<Polyline<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<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>, 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>, 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>, 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>, SegmentConcept OtherSegment>
PolygonSet< 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>
PolygonSet< 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>, PolylineConcept OtherPolyline>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum (const OtherPolyline &other) const
 Returns the regularized Minkowski sum of the two chains (A ⊕ B).
template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum (const OtherChain &other) const
 Returns the regularized Minkowski sum of the two chains (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 Polylineoperator+= (const OtherPoint &translation)
 Translates the polyline by the given point.
template<PointConcept OtherPoint>
constexpr Polylineoperator-= (const OtherPoint &translation)
 Translates the polyline by the negation of the given point.
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Polylineoperator*= (const Scalar &scalar)
 Scales the polyline by the given scalar.
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Polylineoperator/= (const Scalar &scalar)
 Divides the polyline by the given scalar.
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, PolygonConcept OtherPolygon>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > minkowskiSum (const OtherPolygon &other) const
template<class ResultNumber, PolygonWithHolesConcept OtherRegion>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > minkowskiSum (const OtherRegion &other) const
template<class ResultNumber, SegmentConcept OtherSegment>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > minkowskiSum (const OtherSegment &other) const
template<class ResultNumber, OrientedSegmentConcept OtherOriented>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > minkowskiSum (const OtherOriented &other) const
template<class ResultNumber, PolylineConcept OtherPolyline>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > minkowskiSum (const OtherPolyline &other) const
template<class ResultNumber, MonotoneChainConcept OtherChain>
PolygonSet< 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 Polyline< PointType, LabelTypescaledUpX (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Polyline< PointType, LabelTypescaledUpY (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Polyline< PointType, LabelTypescaledDownX (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Polyline< PointType, LabelTypescaledDownY (const OtherNumber scalar) const
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
constexpr Polyline< PointType, LabelTypeflipped (const OldSegment &oldEdge, const NewSegment &newEdge) const

Detailed Description

template<class PointType_, class TLabel>
struct pgl::Polyline< PointType_, TLabel >

Open polygonal chain stored in traversal order; may self-intersect.

An open polygonal chain stored by its vertices in traversal order plus a translation.

Polyline mirrors the storage layout of Polygon — a vector of vertices and a translation_ applied lazily on access — but the vertices form an open chain: n vertices are joined by n - 1 edges and there is no closing edge back to the first vertex. Unlike MonotoneChain, the vertices keep the order they were given in, so the chain may bend backwards, revisit points, and self-intersect; isSimple reports whether it does not.

The constructor stores the sequence exactly as given: no vertex is reordered or removed, and the traversal direction is kept, so a polyline built backwards iterates backwards. A polyline traversed backwards is still the same set of points, so operator==/operator<=> and std::hash read the vertices in a canonical direction instead of the stored one, giving Polyline({a, b, c}) == Polyline({c, b, a}) without ever flipping the stored sequence. Repeated vertices are kept as given. A repeated consecutive vertex produces a zero-length edge; like other degenerate inputs in the library, such a polyline is outside the contract of the geometric predicates (isSimple reports false for it, and isDegenerate is true only when all vertices are equal).

As a 1-dimensional manifold with boundary, the polyline's boundary is its two extreme vertices and its relative interior is everything else (matching the convention of Segment and MonotoneChain). Note that for a closed polyline (first vertex equal to the last) this convention still subtracts that vertex from the interior.

Template Parameters
PointType_The vertex point type.

Member Typedef Documentation

◆ BoundaryType

template<class PointType_, class TLabel>
template<bool Oriented>
using pgl::Polyline< PointType_, TLabel >::BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>>

◆ EdgeIterator

template<class PointType_, class TLabel>
using pgl::Polyline< PointType_, TLabel >::EdgeIterator = BoundaryIterator<false>

◆ LabelType

template<class PointType_, class TLabel>
using pgl::Polyline< PointType_, TLabel >::LabelType = TLabel

◆ NumberType

template<class PointType_, class TLabel>
using pgl::Polyline< PointType_, TLabel >::NumberType = PointType::NumberType

◆ OrientedEdgeIterator

template<class PointType_, class TLabel>
using pgl::Polyline< PointType_, TLabel >::OrientedEdgeIterator = BoundaryIterator<true>

◆ PointType

template<class PointType_, class TLabel>
using pgl::Polyline< PointType_, TLabel >::PointType = PointType_

Constructor & Destructor Documentation

◆ Polyline() [1/4]

template<class PointType_, class TLabel>
pgl::Polyline< PointType_, TLabel >::Polyline ( )
constexprdefault

Creates a polyline with no vertex.

◆ Polyline() [2/4]

template<class PointType_, class TLabel>
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>
pgl::Polyline< PointType_, TLabel >::Polyline ( Range && points)
inlineexplicitconstexpr

Creates a polyline from a range of points.

The points are linked and stored in the given order: nothing is changed — no sorting, no deduplication, no reversal.

Template Parameters
RangeInput range whose elements can be converted to PointType.
Parameters
pointsRange of vertices in traversal order.

◆ Polyline() [3/4]

template<class PointType_, class TLabel>
pgl::Polyline< PointType_, TLabel >::Polyline ( std::initializer_list< NumberType > coords)
inlineexplicitconstexpr

Creates a polyline from a flat list of coordinates.

The values are consumed in pairs (x0, y0, x1, y1, …), each pair forming one vertex, so the list must hold an even number of values. The vertices are stored in the given order (see the range constructor).

Parameters
coordsInterleaved x/y coordinates of the vertices in traversal order.

◆ Polyline() [4/4]

template<class PointType_, class TLabel>
template<PointConcept OtherPointType, class OtherLabelType>
requires std::constructible_from<PointType, const OtherPointType&>
pgl::Polyline< PointType_, TLabel >::Polyline ( const Polyline< OtherPointType, OtherLabelType > & other)
inlineconstexpr

Converts a polyline with compatible vertex type.

The traversal order of the source is preserved.

Template Parameters
OtherPointTypeSource vertex type.
Parameters
otherSource polyline.

Member Function Documentation

◆ bbox()

template<class PointType, class LabelType>
const Rectangle< PointType > & pgl::Polyline< PointType, LabelType >::bbox ( ) const
constexpr

Computes the bounding box of the polyline.

The result is computed on the first call and cached in bbox_; later calls return the stored value. Any operation that modifies the polyline resets the cache.

Complexity: O(n) for n vertices on the first call, O(1) thereafter.

Returns
A constant reference to the rectangle bounding the polyline.

◆ begin()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::begin ( ) const
inlineconstexpr

Returns a constant iterator to the first vertex.

◆ boundaryContains() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [2/19]

template<class PointType_, class TLabel>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherChain & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [3/19]

template<class PointType_, class TLabel>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherConvex & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [4/19]

template<class PointType_, class TLabel>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherDisk & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [5/19]

template<class PointType_, class TLabel>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherHalfplane & ) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [6/19]

template<class PointType_, class TLabel>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherLine & ) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [7/19]

template<class PointType_, class TLabel>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherOrientedLine & ) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [8/19]

template<class PointType_, class TLabel>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherOrientedSegment & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [9/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::boundaryContains ( const OtherPoint & point) const
nodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

The boundary of a polyline is its two extreme vertices (matching the endpoint convention of Segment).

Complexity: O(1).

Template Parameters
OtherPointType of the point.
Parameters
pointPoint to test.
Returns
true if the point equals the first or the last vertex.

Polyline

Open polygonal chain predicates: the boundary of a polyline is its two extreme vertices, matching the endpoint convention of Segment.

◆ boundaryContains() [10/19]

template<class PointType_, class TLabel>
template<PolygonConcept OtherPolygon>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherPolygon & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [11/19]

template<class PointType_, class TLabel>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherPolyline< PointType_, TLabel > & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [12/19]

template<class PointType_, class TLabel>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherRay & ) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [13/19]

template<class PointType_, class TLabel>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherRectangle & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [14/19]

template<class PointType_, class TLabel>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherRegion & other) const
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.

◆ boundaryContains() [15/19]

template<class PointType, class LabelType>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType, LabelType >::boundaryContains ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [16/19]

template<class PointType_, class TLabel>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherSegment & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherSet & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [18/19]

template<class PointType_, class TLabel>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType_, TLabel >::boundaryContains ( const OtherTriangle & other) const
inlinenodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ boundaryContains() [19/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::boundaryContains ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether this shape's boundary contains the other shape (∂A ⊇ B).

◆ cbegin()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::cbegin ( ) const
inlineconstexpr

Returns a constant iterator to the first vertex.

◆ cend()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::cend ( ) const
inlineconstexpr

Returns a constant iterator past the last vertex.

◆ closestPoints()

template<class PointType_, class TLabel>
requires detail::ClosestPointsPairConcept<Polyline<PointType_, TLabel>, OtherShape>
template<class ResultNumber, class OtherShape>
requires detail::ClosestPointsPairConcept<Polyline<PointType_, TLabel>, OtherShape>
auto pgl::Polyline< PointType_, TLabel >::closestPoints ( const OtherShape & other) const
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.

Template Parameters
ResultNumberCoordinate type of the returned points (default: division_result_t).
Warning
A point interior to an element comes from a division, so with an integer ResultNumber it truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ closestSegments()

template<class PointType_, class TLabel>
requires detail::ClosestPairConcept<Polyline<PointType_, TLabel>, OtherShape>
template<class ResultNumber, BoundedPolygonalConcept OtherShape>
requires detail::ClosestPairConcept<Polyline<PointType_, TLabel>, OtherShape>
auto pgl::Polyline< PointType_, TLabel >::closestSegments ( const OtherShape & other) const
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.

Template Parameters
ResultNumberCoordinate type of the returned segments (default: NumberType).
Warning
other's coordinates and labels are re-expressed in this shape's, so a narrower ResultNumber loses them.

◆ contains() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::contains ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

◆ contains() [2/19]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherChain & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

A chain is exactly the union of its edges, so this folds the (gap-sweeping) segment containment over them.

◆ contains() [3/19]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherConvex & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the convex has at most two vertices and they span a subset of the polyline.

◆ contains() [4/19]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherDisk & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if all three boundary points of other are equal and the polyline contains that point.

◆ contains() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the halfplane is degenerate and its unique point lies on the polyline.

◆ contains() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherLine & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the line is degenerate and its unique point lies on the polyline.

◆ contains() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the oriented line is degenerate and its unique point lies on the polyline.

◆ contains() [8/19]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

◆ contains() [9/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherPoint & point) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Complexity: O(n) for n vertices.

Template Parameters
OtherPointType of the point.
Parameters
pointPoint to test.
Returns
true if the point lies on the polyline.

Polyline

Open polygonal chain predicates: the polyline keeps its vertices in traversal order and may self-intersect, so there is no monotone structure to exploit — point location scans the edges and segment containment sweeps the union of collinear edge overlaps.

◆ contains() [10/19]

template<class PointType, class LabelType>
template<PolygonConcept OtherPolygon>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherPolygon & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

A polygon lies on the 1-dimensional polyline exactly when all of its edges do (its interior is then empty), so this folds contains over the polygon's edges.

◆ contains() [11/19]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

A polyline contains another polyline exactly when it contains every edge of the other (and its vertex for a degenerate other).

Complexity: O(m n log n) for m vertices of the other polyline.

◆ contains() [12/19]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherRay & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the ray is degenerate and its unique point lies on the polyline.

◆ contains() [13/19]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherRectangle & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the rectangle is degenerate and its diagonal lies on the polyline.

◆ contains() [14/19]

template<class PointType_, class TLabel>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType_, TLabel >::contains ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

The polyline is the one shape whose complement can come apart, so it does not answer a region by that region's outer polygon: having no area itself, it holds only a region with no area, and then edge by edge. See implementation/contains.hpp.

◆ contains() [15/19]

template<class PointType, class LabelType>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

◆ contains() [16/19]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

A self-intersecting polyline can cover a segment with several, possibly non-consecutive collinear edges, so the segment is contained exactly when the union of its overlaps with the polyline edges covers it with no gap.

Complexity: O(n log n) for n vertices (collecting and sorting the overlaps).

Template Parameters
OtherSegmentType of the other segment.
Parameters
otherSegment to test.
Returns
true if every point of the segment lies on the polyline.

◆ contains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Polyline< PointType_, TLabel >::contains ( const OtherSet & other) const
inlinenodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

◆ contains() [18/19]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::contains ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

Returns
true if the triangle is degenerate and its spanning segment lies on the polyline.

◆ contains() [19/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::contains ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether this shape contains the other shape (A ⊇ B).

◆ convexHull()

template<class PointType_, class TLabel>
Convex< PointType > pgl::Polyline< PointType_, TLabel >::convexHull ( ) const
inlineconstexpr

Returns the convex hull of the polyline's vertices.

◆ crosses() [1/16]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::crosses ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [2/16]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherChain & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [3/16]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherConvex & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [4/16]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherDisk & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [5/16]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [6/16]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherLine & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [7/16]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [8/16]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [9/16]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType_, TLabel >::crosses ( const OtherPoint & ) const
inlinenodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [10/16]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [11/16]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherRay & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [12/16]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherRectangle & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [13/16]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

Polyline

Mutual-cut predicates for an open polygonal chain: a.crosses(b) is a.separates(b) && b.separates(a).

◆ crosses() [14/16]

template<class PointType_, class TLabel>
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
bool pgl::Polyline< PointType_, TLabel >::crosses ( const OtherShape & other) const
inlinenodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [15/16]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::crosses ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ crosses() [16/16]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::crosses ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether the two shapes mutually separate each other (each disconnects the other).

◆ diameter()

template<class PointType_, class TLabel>
Segment< PointType > pgl::Polyline< PointType_, TLabel >::diameter ( ) const
inlineconstexpr

Returns a segment realizing the diameter (the farthest vertex pair).

The farthest pair of vertices lies on the convex hull of the vertex set, so this builds a Convex from the polyline vertices and returns that hull's Convex::diameter(). Distances are compared exactly via squared length.

Returns
A longest segment between two vertices (degenerate if fewer than two distinct vertices).

◆ distanceL1() [1/14]

template<class PointType, class LabelType>
template<class ResultNumber, MonotoneChainConcept OtherChain>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherChain & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [2/14]

template<class PointType, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherConvex & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [3/14]

template<class PointType, class LabelType>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherHalfplane & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [4/14]

template<class PointType, class LabelType>
template<class ResultNumber, LineConcept OtherLine>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherLine & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [5/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedLineConcept OtherOrientedLine>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherOrientedLine & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [6/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [7/14]

template<class PointType, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherPoint & point) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [8/14]

template<class PointType, class LabelType>
template<class ResultNumber, PolylineConcept OtherPolyline>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [9/14]

template<class PointType, class LabelType>
template<class ResultNumber, RayConcept OtherRay>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherRay & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [10/14]

template<class PointType, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherRectangle & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [11/14]

template<class PointType, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherSegment & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [12/14]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& self)
{ o.template distanceL1<ResultNumber>(self); })
auto pgl::Polyline< PointType_, TLabel >::distanceL1 ( const OtherShape & other) const
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.

◆ distanceL1() [13/14]

template<class PointType, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Polyline< PointType, LabelType >::distanceL1 ( const OtherTriangle & other) const
nodiscardconstexpr

Returns the Manhattan (L1) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceL1() [14/14]

template<class PointType_, class TLabel>
template<class ResultNumber = double, PointConcept OtherPoint>
auto pgl::Polyline< PointType_, TLabel >::distanceL1 ( const Shape< OtherPoint > & other) const
inlinenodiscardconstexpr

Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceL1.

◆ distanceLInf() [1/14]

template<class PointType, class LabelType>
template<class ResultNumber, MonotoneChainConcept OtherChain>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherChain & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [2/14]

template<class PointType, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherConvex & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [3/14]

template<class PointType, class LabelType>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherHalfplane & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [4/14]

template<class PointType, class LabelType>
template<class ResultNumber, LineConcept OtherLine>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherLine & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [5/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedLineConcept OtherOrientedLine>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherOrientedLine & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [6/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [7/14]

template<class PointType, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherPoint & point) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [8/14]

template<class PointType, class LabelType>
template<class ResultNumber, PolylineConcept OtherPolyline>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [9/14]

template<class PointType, class LabelType>
template<class ResultNumber, RayConcept OtherRay>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherRay & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [10/14]

template<class PointType, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherRectangle & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [11/14]

template<class PointType, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherSegment & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [12/14]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& self)
{ o.template distanceLInf<ResultNumber>(self); })
auto pgl::Polyline< PointType_, TLabel >::distanceLInf ( const OtherShape & other) const
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.

◆ distanceLInf() [13/14]

template<class PointType, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Polyline< PointType, LabelType >::distanceLInf ( const OtherTriangle & other) const
nodiscardconstexpr

Returns the Chebyshev (LInf) distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Warning
With an integer ResultNumber the exact distance is generally a fraction, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.

◆ distanceLInf() [14/14]

template<class PointType_, class TLabel>
template<class ResultNumber = double, PointConcept OtherPoint>
auto pgl::Polyline< PointType_, TLabel >::distanceLInf ( const Shape< OtherPoint > & other) const
inlinenodiscardconstexpr

Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceLInf.

◆ edges()

template<class PointType_, class TLabel>
std::vector< Segment< PointType > > pgl::Polyline< PointType_, TLabel >::edges ( ) const
inlineconstexpr

Returns the edges of the polyline.

A polyline with n vertices has n - 1 edges (none for an empty or single-vertex polyline); there is no closing edge back to the first vertex.

◆ edgesBegin()

template<class PointType_, class TLabel>
EdgeIterator pgl::Polyline< PointType_, TLabel >::edgesBegin ( ) const
inlineconstexpr

Returns an iterator to the first unoriented edge.

Returns
Iterator to edge (vertex 0, vertex 1).

◆ edgesEnd()

template<class PointType_, class TLabel>
EdgeIterator pgl::Polyline< PointType_, TLabel >::edgesEnd ( ) const
inlineconstexpr

Returns an iterator past the last unoriented edge.

Returns
Sentinel iterator for edgesBegin().

◆ edgesView()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::edgesView ( ) const
inlineconstexpr

Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vector.

Same edge sequence as edges() (n - 1 edges, no closing edge) but with no heap allocation, so it is preferable when the edges are only iterated once — e.g. inside predicate loops.

◆ empty()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::empty ( ) const
inlineconstexpr

Checks whether the polyline has no vertex.

◆ end()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::end ( ) const
inlineconstexpr

Returns a constant iterator past the last vertex.

◆ fbox()

template<class PointType, class LabelType>
template<std::floating_point ResultNumber>
Rectangle< Point< ResultNumber > > pgl::Polyline< PointType, LabelType >::fbox ( ) const
constexpr

Computes the floating-point bounding box of the polyline.

Template Parameters
ResultNumberThe floating-point type for the result.
Returns
A rectangle with floating-point coordinates representing the bounding box.

◆ flip()

template<class PointType, class LabelType>
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
void pgl::Polyline< PointType, LabelType >::flip ( const OldSegment & oldEdge,
const NewSegment & newEdge )
constexpr

Flips oldEdge to newEdge in place.

See flippable for the exact semantics. The flip must be possible. The label is preserved.

Complexity: O(n) for n vertices.

Template Parameters
OldSegmentType of the removed edge.
NewSegmentType of the added edge.
Parameters
oldEdgeEdge to remove (an existing polyline edge).
newEdgeEdge to add in its place.
Precondition
flippable(oldEdge, newEdge).

◆ flippable()

template<class PointType, class LabelType>
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
bool pgl::Polyline< PointType, LabelType >::flippable ( const OldSegment & oldEdge,
const NewSegment & newEdge ) const
nodiscardconstexpr

Tests whether oldEdge can be flipped to newEdge.

A flip removes one edge and adds one edge so that the result is still a single open chain over the very same vertices (a Hamiltonian path move). Removing an edge splits the chain into two sub-paths A (holding the first vertex) and B (holding the last); the new edge rejoins them and therefore has to connect an endpoint of A to an endpoint of B. With A = [p_0 .. p_i] and B = [p_{i+1} .. p_{n-1}] the three non-trivial reconnections are:

  • add (p_i, p_{n-1}) — reverses the suffix B;
  • add (p_0, p_{i+1}) — reverses the prefix A;
  • add (p_0, p_{n-1}) — reverses both.

The flip is possible when oldEdge equals some edge of the polyline, newEdge is non-degenerate, and newEdge is one of the reconnections above (in particular newEdge differs from oldEdge — re-adding the removed edge is not a flip). Both edges are compared as unordered vertex pairs. In a self-intersecting polyline oldEdge may match several edges; the first (smallest-index) edge admitting newEdge as a valid reconnection is used.

Complexity: O(n) for n vertices.

Template Parameters
OldSegmentType of the removed edge.
NewSegmentType of the added edge.
Parameters
oldEdgeEdge to remove (an existing polyline edge).
newEdgeEdge to add in its place.
Returns
true if the flip yields a path over the same vertices.

◆ flipped() [1/2]

template<class PointType_, class TLabel>
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
Polyline< PointType, LabelType > pgl::Polyline< PointType_, TLabel >::flipped ( const OldSegment & oldEdge,
const NewSegment & newEdge ) const
constexpr

◆ flipped() [2/2]

template<class PointType_, class TLabel>
template<SegmentConcept OldSegment, SegmentConcept NewSegment>
Polyline pgl::Polyline< PointType_, TLabel >::flipped ( const OldSegment & oldEdge,
const NewSegment & newEdge ) const
nodiscardconstexpr

Returns the polyline with oldEdge flipped to newEdge.

See flippable for the exact semantics. The flip must be possible.

Complexity: O(n) for n vertices.

Template Parameters
OldSegmentType of the removed edge.
NewSegmentType of the added edge.
Parameters
oldEdgeEdge to remove (an existing polyline edge).
newEdgeEdge to add in its place.
Returns
The flipped polyline.
Precondition
flippable(oldEdge, newEdge).

◆ get()

template<class PointType_, class TLabel>
PointType pgl::Polyline< PointType_, TLabel >::get ( std::ptrdiff_t index) const
inlineconstexpr

Accesses a vertex by index modulo the vertex count.

Unlike Polygon the polyline is not cyclic — edges never wrap around — but get still reduces the index modulo size() (Euclidean, so negative indices count from the back) to satisfy the common vertex access interface of Shape.

Parameters
indexThe index of the vertex, reduced modulo the vertex count.
Returns
The vertex at the reduced index.

◆ getIfPoint()

template<class PointType_, class TLabel>
std::optional< PointType > pgl::Polyline< PointType_, TLabel >::getIfPoint ( ) const
inlinenodiscardconstexpr

Returns the point the polyline collapses to, if it does.

Complexity: O(n), returning at the first differing vertex.

Returns
The common vertex if isPoint, std::nullopt otherwise.

◆ getIfSegment()

template<class PointType_, class TLabel>
std::optional< BoundaryType< false > > pgl::Polyline< PointType_, TLabel >::getIfSegment ( ) const
inlinenodiscardconstexpr

Returns the segment the polyline collapses to, if it does.

Complexity: O(n).

Returns
The spanned segment if isSegment, std::nullopt otherwise.

◆ index()

template<class PointType_, class TLabel>
std::ptrdiff_t pgl::Polyline< PointType_, TLabel >::index ( const PointType & point) const
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; the vertices follow the traversal order, not a searchable order).

Parameters
pointThe vertex to locate.
Returns
The vertex index, or -1 if point is not a vertex.

◆ insert() [1/2]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
void pgl::Polyline< PointType_, TLabel >::insert ( std::size_t index,
const OtherPoint & point )
inlineconstexpr

Inserts a vertex at the given index, shifting the later vertices back.

The vertex becomes (*this)[index]; passing size() appends. The two edges that met at the old index are replaced by three, so the polyline may stop being simple.

Complexity: O(n) for n vertices.

Template Parameters
OtherPointType of the inserted point.
Parameters
indexPosition the new vertex takes, in [0, size()].
pointVertex to insert.

◆ insert() [2/2]

template<class PointType_, class TLabel>
template<std::ranges::input_range Range>
requires (!detail::is_point_v<std::remove_cvref_t<Range>>) && std::convertible_to<std::ranges::range_value_t<Range>, PointType>
void pgl::Polyline< PointType_, TLabel >::insert ( std::size_t index,
Range && points )
inlineconstexpr

Inserts a range of vertices at the given index, shifting the later vertices back.

The range keeps its order: its first point becomes (*this)[index]. Passing size() appends. The points are collected before the insertion, so a range that reads from this polyline (e.g. its own vertices) is safe.

Complexity: O(n + m) for n vertices and m inserted points.

Template Parameters
RangeInput range whose elements can be converted to PointType.
Parameters
indexPosition the first new vertex takes, in [0, size()].
pointsVertices to insert, in traversal order.

◆ interiorContains() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [2/19]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherChain & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [3/19]

template<class PointType_, class TLabel>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherConvex & other) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [4/19]

template<class PointType_, class TLabel>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherDisk & other) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherLine & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [8/19]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [9/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherPoint & point) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

The relative interior of a polyline is the polyline minus its two extreme vertices.

Complexity: O(n) for n vertices.

Template Parameters
OtherPointType of the point.
Parameters
pointPoint to test.
Returns
true if the point lies on the polyline and is not an extreme vertex.

Polyline

Open polygonal chain predicates. The relative interior of a polyline is the polyline minus its two extreme vertices as a point set: a self-intersecting polyline may pass through an extreme vertex again mid-chain, and that point is still excluded.

◆ interiorContains() [10/19]

template<class PointType_, class TLabel>
template<PolygonConcept OtherPolygon>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherPolygon & other) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [11/19]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [12/19]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherRay & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [13/19]

template<class PointType_, class TLabel>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherRectangle & other) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [14/19]

template<class PointType_, class TLabel>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [15/19]

template<class PointType, class LabelType>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [16/19]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

Complexity: O(n log n) for n vertices (see contains).

Template Parameters
OtherSegmentType of the other segment.
Parameters
otherSegment to test.
Returns
true if the polyline contains the segment and the segment avoids both extreme vertices of the polyline.

◆ interiorContains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Polyline< PointType_, TLabel >::interiorContains ( const OtherSet & other) const
inlinenodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [18/19]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorContains() [19/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::interiorContains ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).

◆ interiorsIntersect() [1/16]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::interiorsIntersect ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [2/16]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherChain & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [3/16]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherConvex & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [4/16]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherDisk & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [5/16]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [6/16]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherLine & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [7/16]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [8/16]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [9/16]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherPoint & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

A point's interior is the point itself, so this matches interiorContains.

Complexity: O(n) for n vertices.

Polyline

Open polygonal chain predicates. The polyline's relative interior is the polyline minus its two extreme points (a self-intersecting polyline may pass through an extreme again mid-chain, and that point is still excluded), so the tests work with closed edges and explicitly discard meeting points that coincide with an excluded extreme or endpoint.

◆ interiorsIntersect() [10/16]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

All-pairs edge test plus the crossing-at-a-non-extreme-vertex checks in both directions.

Complexity: O(n m) for polylines with n and m vertices.

◆ interiorsIntersect() [11/16]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherRay & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [12/16]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherRectangle & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [13/16]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

The polyline's relative interior is the polyline minus its extreme vertices, so a polyline vertex other than the extremes counts as interior: a segment whose open part passes exactly through such a vertex engages this predicate even though it crosses no open edge.

Complexity: O(n) for n vertices.

Template Parameters
OtherSegmentType of the other segment.
Parameters
otherSegment to test.
Returns
true if the polyline minus its extremes meets the open segment.

◆ interiorsIntersect() [14/16]

template<class PointType_, class TLabel>
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
bool pgl::Polyline< PointType_, TLabel >::interiorsIntersect ( const OtherShape & other) const
inlinenodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [15/16]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ interiorsIntersect() [16/16]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::interiorsIntersect ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).

◆ intersection() [1/15]

template<class PointType_, class TLabel>
template<class ResultNumber = NumberType, class EmptyPoint>
EmptyShape< EmptyPoint > pgl::Polyline< PointType_, TLabel >::intersection ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.

◆ intersection() [2/15]

template<class PointType, class LabelType>
template<class ResultNumber, MonotoneChainConcept OtherChain>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherChain & other) const
nodiscardconstexpr

Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments sorted by lexicographic order.

All-pairs edge test, preceded by a bounding-box cull; the pieces are coalesced like intersection(const OtherPolyline&) const.

Complexity: O(n m) for a polyline with n vertices and a chain with m vertices, plus coalescing the resulting pieces.

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [3/15]

template<class PointType, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherConvex & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [4/15]

template<class PointType, class LabelType>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherHalfplane & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [5/15]

template<class PointType, class LabelType>
template<class ResultNumber, LineConcept OtherLine>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherLine & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [6/15]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedLineConcept OtherOrientedLine>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherOrientedLine & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [7/15]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [8/15]

template<class PointType, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
std::optional< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherPoint & other) const
nodiscardconstexpr

Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.

◆ intersection() [9/15]

template<class PointType, class LabelType>
template<class ResultNumber, PolylineConcept OtherPolyline>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the intersection of the two polylines (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Two polylines can overlap along collinear sub-segments, so the result is a vector of point-or-segment variants. Pieces are maximal: collinear touching overlaps are coalesced into single segments — even when they come from non-consecutive edges of a self-intersecting polyline — and points covered by a reported segment or repeated by several edge pairs are dropped. Computed by an all-pairs edge test with a bounding-box cull.

Complexity: O(n m) for polylines with n and m vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
OtherPolylineType of the other polyline.
Parameters
otherPolyline to intersect with.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [10/15]

template<class PointType, class LabelType>
template<class ResultNumber, RayConcept OtherRay>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherRay & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [11/15]

template<class PointType, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherRectangle & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [12/15]

template<class PointType, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherSegment & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [13/15]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape&
o, const Polyline& self) { o.template intersection<ResultNumber>(self); })
auto pgl::Polyline< PointType_, TLabel >::intersection ( const OtherShape & other) const
inlinenodiscardconstexpr

Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.

Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [14/15]

template<class PointType, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::intersection ( const OtherTriangle & other) const
nodiscardconstexpr

Returns the intersection with a one-dimensional or convex shape (A ∩ B), a sequence of points and segments sorted by lexicographic order.

Folds the shape over the polyline edges, delegating each edge to the segment-vs-shape intersection, then coalesces the pieces like intersection(const OtherPolyline&) const.

Complexity: O(n) segment intersections for n vertices, plus coalescing the resulting pieces (quadratic in their count).

Template Parameters
ResultNumberNumber type of the returned coordinates.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [15/15]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Polyline< PointType_, TLabel >::intersection ( const Shape< OtherPoint > & other) const
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.

Returns
The intersection wrapped in a Shape, rather than the tighter type the concrete pair would answer with: which alternative other holds is not known until run time, so neither is the result's.

◆ intersects() [1/16]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::intersects ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [2/16]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherChain & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

Folds the chain's own (pruned) segment test over the polyline edges.

Complexity: O(n (log m + k)) for a polyline with n vertices and a chain with m vertices.

◆ intersects() [3/16]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherConvex & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [4/16]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherDisk & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [5/16]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [6/16]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherLine & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [7/16]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [8/16]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [9/16]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherPoint & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

Complexity: O(n) for n vertices.

Polyline

Open polygonal chain predicates: a polyline may self-intersect, so there is no monotone structure to prune the edge tests — the scans are linear in one polyline and all-pairs between two.

◆ intersects() [10/16]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

All-pairs edge test, preceded by a bounding-box cull.

Complexity: O(n m) for polylines with n and m vertices.

Template Parameters
OtherPolylineType of the other polyline.
Parameters
otherPolyline to test.
Returns
true if the polylines share at least one point.

◆ intersects() [11/16]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherRay & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [12/16]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherRectangle & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [13/16]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

Every edge is tested against the segment; a self-intersecting polyline has no monotone structure to prune the scan.

Complexity: O(n) for n vertices.

Template Parameters
OtherSegmentType of the other segment.
Parameters
otherSegment to test.
Returns
true if the polyline and the segment share at least one point.

◆ intersects() [14/16]

template<class PointType_, class TLabel>
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>)
bool pgl::Polyline< PointType_, TLabel >::intersects ( const OtherShape & other) const
inlinenodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [15/16]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::intersects ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ intersects() [16/16]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::intersects ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).

◆ isDegenerate()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::isDegenerate ( ) const
inlineconstexpr

Checks if the polyline is degenerate (all vertices are equal, so it covers at most a single point).

An empty or single-vertex polyline is degenerate. Note the contrast with MonotoneChain::isDegenerate: a polyline may repeat one point many times and still be a single geometric point.

Complexity: O(n).

◆ isPoint()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::isPoint ( ) const
inlinenodiscardconstexpr

Checks whether the polyline covers exactly one point.

Same as isDegenerate except for the empty polyline, which has no defining vertex and so is not a point.

Complexity: O(n), returning at the first differing vertex.

◆ isSegment()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::isSegment ( ) const
inlinenodiscardconstexpr

Checks whether the polyline covers exactly one segment of positive length.

True when the vertices are collinear but not all equal. The polyline is connected, so collinear vertices make its edges cover the single segment spanning them, however many times they retrace it.

Complexity: O(n), returning at the first non-collinear vertex.

◆ isSimple()

template<class PointType_, class TLabel>
template<class Rational>
bool pgl::Polyline< PointType_, TLabel >::isSimple ( ) const
nodiscard

Tests whether the polyline is simple (it does not touch or cross itself).

Tests whether the polyline is simple.

Simple means no two non-adjacent edges share a point and consecutive edges meet only at their shared vertex; in an open chain the first and last edges are not adjacent, so a closed polyline (first vertex equal to the last) is not simple. A zero-length edge (repeated consecutive vertex) also makes the polyline not simple. A polyline with fewer than two vertices is vacuously simple.

Uses a brute-force pairwise edge test in O(n^2) for few edges (n <= 8) or floating-point coordinates, and the Bentley-Ottmann sweep (O(n log n)) for larger exact (integer or rational) polylines.

Template Parameters
RationalExact rational type used by the sweep for large polylines.
Returns
true if no two edges meet except consecutive edges at their shared vertex.

Takes the same three paths as Polygon::isSimple, over the chain's edges rather than a ring's: the exact sweep line for integer and rational coordinates, the bounding-box sweep for large floating-point ones, and the pairwise scan for the small ones.

Template Parameters
RationalExact rational type used internally by the sweep line.
Returns
true if the edges only meet at the shared endpoints of consecutive edges.

◆ isUndefined()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::isUndefined ( ) const
inlinenodiscardconstexpr

Checks whether the polyline is degenerate without covering a point or a segment.

True only for the empty polyline, which has no defining vertex: any other degenerate polyline has all vertices equal and is therefore a point.

Complexity: O(1).

◆ label()

template<class PointType_, class TLabel>
template<class A = LabelType>
requires (detail::has_label_v<A>)
A & pgl::Polyline< PointType_, TLabel >::label ( ) const
inlineconstexpr

Returns the polyline label.

The label is mutable even through a const polyline: it is metadata that does not participate in equality, hashing, or geometric predicates.

Returns
Reference to the stored label.

◆ latticePoints()

template<class PointType, class LabelType>
requires (detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
template<class ResultNumber>
requires (detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
std::vector< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType, LabelType >::latticePoints ( ) const
nodiscard

Returns the integer points the polyline contains.

The lattice points of the edges, one edge at a time in traversal order, with each point kept the first time the polyline reaches it: a vertex shared by two edges appears once, and so does a point the polyline crosses or retraces. A single vertex answers for itself.

Template Parameters
ResultNumberInteger 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.
Returns
The lattice points, each of them once, carrying no label.
Exceptions
std::logic_errorIf a coordinate is not finite, or a lattice point of the shape does not fit ResultNumber.
std::length_errorIf there are more of them than a vector holds.

◆ length()

template<class PointType, class LabelType>
template<class ApproximateNumber>
ApproximateNumber pgl::Polyline< PointType, LabelType >::length ( ) const

Computes the Euclidean length of the polyline (the sum of its edge lengths).

A self-overlapping polyline counts every traversal of a repeated part.

Template Parameters
ApproximateNumberThe floating-point type for the result.

◆ lengthL1()

template<class PointType, class LabelType>
auto pgl::Polyline< PointType, LabelType >::lengthL1 ( ) const
constexpr

Computes the Manhattan (L1) length of the polyline.

◆ lengthLInf()

template<class PointType, class LabelType>
auto pgl::Polyline< PointType, LabelType >::lengthLInf ( ) const
constexpr

Computes the Chebyshev (LInf) length of the polyline.

◆ minkowskiErosion() [1/2]

template<class PointType_, class TLabel>
requires (!MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape> && BoundedPolygonalConcept<OtherShape>)
template<class ResultNumber, class OtherShape>
requires (!MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape> && BoundedPolygonalConcept<OtherShape>)
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiErosion ( const OtherShape & other) const
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.

Template Parameters
ResultNumberCoordinate type of the result.
OtherShapeType of the shape to erode by.
Parameters
otherShape to erode by.
Returns
The erosion, as a PolygonSet.
Exceptions
std::logic_errorwhen other covers no point: that erosion is the whole plane, which no set of bounded regions represents.

◆ minkowskiErosion() [2/2]

template<class PointType, class LabelType>
requires MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape>
template<class OtherShape>
requires MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape>
auto pgl::Polyline< PointType, LabelType >::minkowskiErosion ( const OtherShape & other) const
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 polyline has no area, so the erosion of one has none either.

Eroding by a shape that covers no point is the whole plane, which a HalfplaneIntersection returns and the tighter result types cannot.

Template Parameters
OtherShapeType of the shape to erode by.
Parameters
otherShape to erode by.
Returns
The erosion, in the tightest type that represents it.

◆ minkowskiSum() [1/21]

template<class PointType_, class TLabel>
template<class ResultNumber, MonotoneChainConcept OtherChain>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherChain & other) const

◆ minkowskiSum() [2/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherChain & other) const
nodiscard

Returns the regularized Minkowski sum of the two chains (A ⊕ B).

A MonotoneChain operand is a polyline that happens to be sorted, and it sums here exactly as one: its monotonicity buys nothing against a receiver that may bend back on itself. A polyline outranks a chain and so owns the pair, which the chain's own forwarder reaches.

◆ minkowskiSum() [3/21]

template<class PointType_, class TLabel>
template<class ResultNumber, ConvexConcept OtherConvex>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherConvex & other) const

◆ minkowskiSum() [4/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherConvex & other) const
nodiscard

Returns the regularized Minkowski sum of the two shapes (A ⊕ B).

◆ minkowskiSum() [5/21]

template<class PointType_, class TLabel>
template<class ResultNumber, OrientedSegmentConcept OtherOriented>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherOriented & other) const

◆ minkowskiSum() [6/21]

template<class PointType_, class TLabel>
template<class ResultNumber, PolygonConcept OtherPolygon>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherPolygon & other) const

◆ minkowskiSum() [7/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherPolygon & other) const
nodiscard

Returns the regularized Minkowski sum of the two shapes (A ⊕ B).

The one non-convex summand a chain takes: a Polygon reaches around the chain as readily as the chain bends around it, so here either operand's concavity can strand a cavity, where with a convex summand only the chain's turns can. It is decomposed the way the region-valued sums decompose it — the triangles of its triangulated domain, or its edges when it has no area — while the chain contributes its edges.

Complexity: one convex merge per pair of chain edge and operand triangle, then a constrained triangulation over the arrangement of all of them.

◆ minkowskiSum() [8/21]

template<class PointType_, class TLabel>
template<class ResultNumber, PolylineConcept OtherPolyline>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherPolyline< PointType_, TLabel > & other) const

◆ minkowskiSum() [9/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscard

Returns the regularized Minkowski sum of the two chains (A ⊕ B).

Two chains, and between them not a scrap of area — and the sum has some anyway, for the reason a segment operand does: an edge of each spans a parallelogram unless the two are parallel. It is the same construction as every other sum here, with both operands contributing their edges as their decomposition, and the same regularized, set-valued contract that minkowskiSum(const OtherSegment&) const has — a segment operand being the one-edge case of this one.

Nothing about a valid pair of chains keeps the answer in one piece, so there is no body here and no precondition to observe: two chains that share a direction sweep out nothing along it, and what is left can be in pieces or empty. Two parallel segments spelled as chains are the smallest example, and they come back empty.

Complexity: one convex merge per pair of edges, then a constrained triangulation over the arrangement of all of them.

Template Parameters
ResultNumberThe number type for the result.
Parameters
otherThe chain to sum with.
Returns
The pieces of the sum, in canonical order.

◆ minkowskiSum() [10/21]

template<class PointType_, class TLabel>
template<class ResultNumber, RectangleConcept OtherRectangle>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherRectangle & other) const

◆ minkowskiSum() [11/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherRectangle & other) const
nodiscard

Returns the regularized Minkowski sum of the two shapes (A ⊕ B).

◆ minkowskiSum() [12/21]

template<class PointType_, class TLabel>
template<class ResultNumber, PolygonWithHolesConcept OtherRegion>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherRegion & other) const

◆ minkowskiSum() [13/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherRegion & other) const
nodiscard

Returns the regularized Minkowski sum of the two shapes (A ⊕ B).

A region summand brings what it brings to every sum: its holes need no handling, being simply where its decomposition has no piece, while its slits do — a stretch of boundary two of its rings share carries no area beside it and yet sweeps out area along the chain exactly as a triangle does, so it joins the decomposition.

The one case worth knowing is a slit the chain drags along the slit's own direction: that sweep is a segment, so the regularization drops it and the answer is strictly smaller than A ⊕ B. It is the same rule that makes a summand with no area at all come back empty, and it is reachable here from a perfectly ordinary rectilinear region and chain.

That case is also the one that can cost a region its body, which is what this overload's single-region result is contracted on: a slit cutting the operand's interior in two leaves the sum in as many pieces, of which one comes back. A region whose slits leave its interior connected — or that has none — is a body and is on the contract.

Complexity: one convex merge per pair of chain edge and operand piece, then a constrained triangulation over the arrangement of all of them.

◆ minkowskiSum() [14/21]

template<class PointType_, class TLabel>
template<class ResultNumber, SegmentConcept OtherSegment>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherSegment & other) const

◆ minkowskiSum() [15/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherSegment>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< 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.

◆ minkowskiSum() [16/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherSegment & other) const
nodiscard

Returns the regularized Minkowski sum of the two shapes (A ⊕ B).

The one operand here with no area of its own, and the sum still has some: an edge of the chain summed with the segment is the parallelogram they span, which is flat only where the two are parallel. So a chain that bends sweeps a band of material along itself whichever direction the segment points, and that band closes over a cavity exactly as a summand with area does — a closed chain still comes back as a region with a hole.

This is the pair where the regularization is easiest to trip over, because the receiver's own edges are what sweep. An edge parallel to the segment sweeps a segment, which the regularization drops: a straight chain summed along its own direction comes back empty — as does any chain against a summand collapsed to a point — and a closed rectilinear chain summed with an axis-parallel segment comes back as two disjoint regions, the sweeps of the two edges across it, with what joined them dropped. Every one of those is A ⊕ B losing what has no area, not the sum being unsupported.

Complexity: one convex merge per edge of the chain, then a constrained triangulation over the arrangement of all of them.

◆ minkowskiSum() [17/21]

template<class PointType_, class TLabel>
template<class ResultNumber, PolygonSetConcept OtherSet>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherSet & other) const

◆ minkowskiSum() [18/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< 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.

◆ minkowskiSum() [19/21]

template<class PointType, class LabelType>
requires MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape>
template<class OtherShape>
requires MinkowskiSummableConcept<Polyline<PointType_, TLabel>, OtherShape>
auto pgl::Polyline< PointType, LabelType >::minkowskiSum ( const OtherShape & other) const
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.

Template Parameters
OtherShapeType of the other shape.
Parameters
otherShape to sum with.
Returns
The Minkowski sum, in the tightest type that represents it.

◆ minkowskiSum() [20/21]

template<class PointType_, class TLabel>
template<class ResultNumber, TriangleConcept OtherTriangle>
PolygonWithHoles< Point< ResultNumber, typename PointType_::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherTriangle & other) const

◆ minkowskiSum() [21/21]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > pgl::Polyline< PointType_, TLabel >::minkowskiSum ( const OtherTriangle & 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 polyline has no area of its own, but sweeping another shape along it has some: the chain is one-dimensional and may bend back on itself, so the swept material can close over a hole — a closed chain is the plainest example, and an open one whose ends come within the summand's reach of each other does it too — and no other shape in the library can say so.

The operand must be a body — the closure of a connected, non-empty interior — and it is the operand that has to be one, since the receiver never is. A body thickens the whole polyline: the sum covers ⋃_{a ∈ A} (a + B°), which is connected along the chain and open, and the sum is its closure. So the answer is one region. A degenerate operand — a Rectangle collapsed to a segment, say — is not on this contract: the regularization can then leave the sum in pieces, of which one comes back. Sum with a Segment instead for the pair that is contracted for two thin operands and returns every piece. An empty or wholly flat regularized sum is the empty region.

Distinguish this from minkowskiSum(const OtherShape&) const, which sums a Point — a translation, giving back a Polyline — and nothing else: a polyline is not convex, so MinkowskiSummableConcept rejects every other pair. A second Polyline is not an operand.

Complexity: one convex merge per edge of the polyline, then a constrained triangulation over the arrangement of all of them.

Template Parameters
ResultNumberThe number type for the result.
Parameters
otherThe shape to sum with.
Returns
The sum, as one region.
Precondition
The operand is a body.
Note
Every vertex of every piece sum is a sum of two input vertices, so the pieces are exact; only their union can put a vertex at a crossing, and that arrangement is built over exact rationals and converted to ResultNumber only at the end.

◆ operator*=()

template<class PointType_, class TLabel>
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
Polyline & pgl::Polyline< PointType_, TLabel >::operator*= ( const Scalar & scalar)
inlineconstexpr

Scales the polyline by the given scalar.

Complexity: O(n) for n vertices. The traversal order is preserved, even for a negative factor, which merely reverses the lexicographic order of the extremes.

◆ operator+=()

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
Polyline & pgl::Polyline< PointType_, TLabel >::operator+= ( const OtherPoint & translation)
inlineconstexpr

Translates the polyline by the given point.

Complexity: O(1).

◆ operator-=()

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
Polyline & pgl::Polyline< PointType_, TLabel >::operator-= ( const OtherPoint & translation)
inlineconstexpr

Translates the polyline by the negation of the given point.

Complexity: O(1).

◆ operator/=()

template<class PointType_, class TLabel>
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
Polyline & pgl::Polyline< PointType_, TLabel >::operator/= ( const Scalar & scalar)
inlineconstexpr

Divides the polyline by the given scalar.

Complexity: O(n) for n vertices; preserves the traversal order like operator*=.

◆ operator<=>()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::operator<=> ( const Polyline< PointType_, TLabel > & other) const
inlineconstexpr

Compares two polylines by their canonical vertex sequences.

The stored direction is irrelevant: each side is read through canonicalAt, so the order is the one induced by the lexicographically smaller of each sequence and its reversal.

Complexity: O(n) for n vertices.

◆ operator==()

template<class PointType_, class TLabel>
bool pgl::Polyline< PointType_, TLabel >::operator== ( const Polyline< PointType_, TLabel > & other) const
inlineconstexpr

Checks equality of two polylines.

Complexity: O(n) for n vertices.

Returns
True if both polylines have the same vertices in the same order, up to the traversal direction: a polyline equals its reversal.

◆ operator[]()

template<class PointType_, class TLabel>
const PointType pgl::Polyline< PointType_, TLabel >::operator[] ( std::size_t index) const
inlineconstexpr

Accesses a vertex by index (in traversal order).

Parameters
indexThe index of the vertex.
Returns
The vertex at the given index.

◆ orientedEdges()

template<class PointType_, class TLabel>
std::vector< OrientedSegment< PointType > > pgl::Polyline< PointType_, TLabel >::orientedEdges ( ) const
inlineconstexpr

Returns the oriented edges of the polyline, each directed from vertex i to vertex i + 1 in traversal order.

◆ orientedEdgesBegin()

template<class PointType_, class TLabel>
OrientedEdgeIterator pgl::Polyline< PointType_, TLabel >::orientedEdgesBegin ( ) const
inlineconstexpr

Returns an iterator to the first oriented edge.

Returns
Iterator to edge vertex 0 -> vertex 1.

◆ orientedEdgesEnd()

template<class PointType_, class TLabel>
OrientedEdgeIterator pgl::Polyline< PointType_, TLabel >::orientedEdgesEnd ( ) const
inlineconstexpr

Returns an iterator past the last oriented edge.

Returns
Sentinel iterator for orientedEdgesBegin().

◆ orientedEdgesView()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::orientedEdgesView ( ) const
inlineconstexpr

Lazy view counterpart of orientedEdges(); see edgesView().

◆ pointInside()

template<class PointType, class LabelType>
template<class ResultNumber>
Point< ResultNumber > pgl::Polyline< PointType, LabelType >::pointInside ( ) const
nodiscardconstexpr

Returns a point inside the polyline.

This is the point inside the segment formed by the first two vertices, i.e. the midpoint of that edge.

Template Parameters
ResultNumberCoordinate type of the result.
Warning
Divides coordinates by 2. Inexact for odd integer coordinates.

◆ polygonIntersection()

template<class PointType, class LabelType>
requires (PolygonConcept<OtherArea> || PolygonWithHolesConcept<OtherArea>)
template<class ResultNumber, class OtherArea>
requires (PolygonConcept<OtherArea> || PolygonWithHolesConcept<OtherArea>)
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Polyline< PointType, LabelType >::polygonIntersection ( const OtherArea & other) const
nodiscardconstexpr

Returns the intersection with a polygon or a region (A ∩ B), a sequence of points and segments sorted by lexicographic order.

The area may be non-convex — and, for a PolygonWithHoles, not simply connected — so its intersection with a single edge can already split into several disjoint pieces; each edge is clipped against the area and the pieces are coalesced like intersection(const OtherPolyline&) const.

Note
This is the shared implementation of the area–polyline clip, not an intersection overload: Polygon and PolygonWithHoles both outrank Polyline, so Polygon::intersection(const OtherPolyline&) const and PolygonWithHoles::intersection(const OtherPolyline&) const own the pairs and call this helper (and polyline.intersection(area) reaches it by forwarding up). Keeping it here reuses the polyline's coalescing and labels the pieces with the polyline's label.

Complexity: O(n) area-vs-segment clips for n vertices, plus coalescing the resulting pieces.

Template Parameters
ResultNumberNumber type of the returned coordinates.
OtherAreaType of the polygon or region.
Parameters
otherPolygon or region to intersect with.
Returns
Vector of points and segments forming the intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ pushBack() [1/2]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
void pgl::Polyline< PointType_, TLabel >::pushBack ( const OtherPoint & point)
inlineconstexpr

Appends a vertex, extending the polyline by one edge.

Same as insert(size(), point).

Complexity: amortized O(1).

Template Parameters
OtherPointType of the appended point.
Parameters
pointVertex to append.

◆ pushBack() [2/2]

template<class PointType_, class TLabel>
template<std::ranges::input_range Range>
requires (!detail::is_point_v<std::remove_cvref_t<Range>>) && std::convertible_to<std::ranges::range_value_t<Range>, PointType>
void pgl::Polyline< PointType_, TLabel >::pushBack ( Range && points)
inlineconstexpr

Appends a range of vertices in order.

Same as insert(size(), points).

Complexity: O(m) for m appended points.

Template Parameters
RangeInput range whose elements can be converted to PointType.
Parameters
pointsVertices to append, in traversal order.

◆ rotate90()

template<class PointType, class LabelType>
void pgl::Polyline< PointType, LabelType >::rotate90 ( int k = 1)
constexpr

Rotates the polyline by 90k degrees around the origin in place.

Parameters
kNumber of 90-degree CCW rotations (may be negative).

◆ rotated90()

template<class PointType, class LabelType>
Polyline< PointType, LabelType > pgl::Polyline< PointType, LabelType >::rotated90 ( int k = 1) const
nodiscardconstexpr

Returns the polyline rotated by 90k degrees around the origin.

The vertex sequence, including its direction, is preserved (rotation is a rigid motion).

Parameters
kNumber of 90-degree CCW rotations (may be negative).
Returns
Rotated polyline.

◆ samePointSet()

template<class PointType, class LabelType>
template<AnyShapeConcept OtherShape>
bool pgl::Polyline< PointType, LabelType >::samePointSet ( const OtherShape & other) const
nodiscardconstexpr

Tests whether another shape defines exactly the same point set.

◆ scaledDownX() [1/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline< PointType, LabelType > pgl::Polyline< PointType_, TLabel >::scaledDownX ( const OtherNumber scalar) const
constexpr

◆ scaledDownX() [2/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline pgl::Polyline< PointType_, TLabel >::scaledDownX ( const OtherNumber scalar) const
nodiscardconstexpr

Returns the polyline with its x-coordinates divided by a divisor.

◆ scaledDownY() [1/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline< PointType, LabelType > pgl::Polyline< PointType_, TLabel >::scaledDownY ( const OtherNumber scalar) const
constexpr

◆ scaledDownY() [2/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline pgl::Polyline< PointType_, TLabel >::scaledDownY ( const OtherNumber scalar) const
nodiscardconstexpr

Returns the polyline with its y-coordinates divided by a divisor.

◆ scaleDownX()

template<class PointType, class LabelType>
template<class OtherNumber>
void pgl::Polyline< PointType, LabelType >::scaleDownX ( const OtherNumber scalar)
constexpr

Divides the polyline's x-coordinates by a divisor in place.

◆ scaleDownY()

template<class PointType, class LabelType>
template<class OtherNumber>
void pgl::Polyline< PointType, LabelType >::scaleDownY ( const OtherNumber scalar)
constexpr

Divides the polyline's y-coordinates by a divisor in place.

◆ scaledUpX() [1/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline< PointType, LabelType > pgl::Polyline< PointType_, TLabel >::scaledUpX ( const OtherNumber scalar) const
constexpr

◆ scaledUpX() [2/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline pgl::Polyline< PointType_, TLabel >::scaledUpX ( const OtherNumber scalar) const
nodiscardconstexpr

Returns the polyline with its x-coordinates multiplied by a factor.

◆ scaledUpY() [1/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline< PointType, LabelType > pgl::Polyline< PointType_, TLabel >::scaledUpY ( const OtherNumber scalar) const
constexpr

◆ scaledUpY() [2/2]

template<class PointType_, class TLabel>
template<class OtherNumber>
Polyline pgl::Polyline< PointType_, TLabel >::scaledUpY ( const OtherNumber scalar) const
nodiscardconstexpr

Returns the polyline with its y-coordinates multiplied by a factor.

◆ scaleUpX()

template<class PointType, class LabelType>
template<class OtherNumber>
void pgl::Polyline< PointType, LabelType >::scaleUpX ( const OtherNumber scalar)
constexpr

Multiplies the polyline's x-coordinates by a factor in place.

◆ scaleUpY()

template<class PointType, class LabelType>
template<class OtherNumber>
void pgl::Polyline< PointType, LabelType >::scaleUpY ( const OtherNumber scalar)
constexpr

Multiplies the polyline's y-coordinates by a factor in place.

◆ separates() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Polyline< PointType_, TLabel >::separates ( const EmptyShape< EmptyPoint > & ) const
inlinenodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [2/19]

template<class PointType, class LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherChain & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

The chain is a 1-dimensional set like the polyline, so its free pieces are joined geometrically (see detail::separates1DSet).

◆ separates() [3/19]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherConvex & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [4/19]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherDisk & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherHalfplane & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherLine & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherOrientedLine & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [8/19]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [9/19]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType_, TLabel >::separates ( const OtherPoint & ) const
inlinenodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

Removing anything from a single point never disconnects it.

◆ separates() [10/19]

template<class PointType, class LabelType>
template<PolygonConcept OtherPolygon>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherPolygon & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [11/19]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

Set semantics: the other polyline's free pieces may reconnect through its own self-intersections, so removing an interior point of a closed polyline does not disconnect it.

Complexity: O((n m)^2) piece tests for polylines with n and m vertices.

◆ separates() [12/19]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherRay & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [13/19]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherRectangle & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [14/19]

template<class PointType, class LabelType>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherRegion & other) const
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.

◆ separates() [15/19]

template<class PointType, class LabelType>
template<HalfplaneIntersectionConcept OtherRegion>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherRegion & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [16/19]

template<class PointType, class LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherSegment & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

True when the segment minus the polyline has at least two connected components. Because the polyline may self-intersect, the pieces are collected as a set and joined through every shared point that survives the removal (see detail::separates1DSet).

Complexity: O(n^2) exact piece tests for n vertices.

◆ separates() [17/19]

template<class PointType, class LabelType>
template<PolygonSetConcept OtherSet>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherSet & other) const
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.

◆ separates() [18/19]

template<class PointType, class LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Polyline< PointType, LabelType >::separates ( const OtherTriangle & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ separates() [19/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Polyline< PointType, LabelType >::separates ( const Shape< OtherPoint > & other) const
nodiscardconstexpr

Tests whether removing this shape disconnects the other shape (B∖A is disconnected).

◆ set()

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
void pgl::Polyline< PointType_, TLabel >::set ( std::size_t index,
const OtherPoint & point )
inlineconstexpr

Replaces the vertex at the given index.

The stored vertices are kept relative to a lazy translation, so the given absolute position has that translation subtracted before it is stored; the rest of the polyline is untouched. Drops the cached bounding box and hash.

Complexity: O(1).

Template Parameters
OtherPointType of the new vertex.
Parameters
indexThe index of the vertex to replace.
pointThe new vertex position.

◆ size()

template<class PointType_, class TLabel>
std::size_t pgl::Polyline< PointType_, TLabel >::size ( ) const
inlineconstexpr

Returns the number of vertices in the polyline.

◆ squaredDistance() [1/14]

template<class PointType, class LabelType>
template<class ResultNumber, class DiskPointType, class DiskLabel>
detail::floating_result_t< ResultNumber > pgl::Polyline< PointType, LabelType >::squaredDistance ( const Disk< DiskPointType, DiskLabel > & disk) const
nodiscard

Returns the squared Euclidean distance to a disk.

Forwards to Disk::squaredDistance's model. 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.

◆ squaredDistance() [2/14]

template<class PointType, class LabelType>
template<class ResultNumber, MonotoneChainConcept OtherChain>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherChain & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [3/14]

template<class PointType, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherConvex & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [4/14]

template<class PointType, class LabelType>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherHalfplane & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [5/14]

template<class PointType, class LabelType>
template<class ResultNumber, LineConcept OtherLine>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherLine & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [6/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedLineConcept OtherOrientedLine>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherOrientedLine & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [7/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [8/14]

template<class PointType, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherPoint & point) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [9/14]

template<class PointType, class LabelType>
template<class ResultNumber, PolylineConcept OtherPolyline>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherPolyline< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [10/14]

template<class PointType, class LabelType>
template<class ResultNumber, RayConcept OtherRay>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherRay & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [11/14]

template<class PointType, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherRectangle & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [12/14]

template<class PointType, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherSegment & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ squaredDistance() [13/14]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Polyline>) && requires(const OtherShape& o, const Polyline& self)
{ o.template squaredDistance<ResultNumber>(self); })
auto pgl::Polyline< PointType_, TLabel >::squaredDistance ( const OtherShape & other) const
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.

◆ squaredDistance() [14/14]

template<class PointType, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Polyline< PointType, LabelType >::squaredDistance ( const OtherTriangle & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the shapes intersect, otherwise the minimum over the polyline edges. The polyline must have at least one edge.

Complexity: O(n) edge queries for n vertices, plus the intersection test.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
Warning
With an integer 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.

◆ vertices()

template<class PointType_, class TLabel>
std::vector< PointType > pgl::Polyline< PointType_, TLabel >::vertices ( ) const
inlineconstexpr

Returns the vertices of the polyline (translation applied).

◆ verticesView()

template<class PointType_, class TLabel>
auto pgl::Polyline< PointType_, TLabel >::verticesView ( ) const
inlineconstexpr

Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.

Same traversal-order vertex sequence as vertices(), with no heap allocation. The polyline is itself a vertex range, so this is just begin() and end() packaged as a view for callers that take one.