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

Closed convex polygon stored by its vertices. More...

#include <convex.hpp>

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

Classes

class  BoundaryIterator
 Forward iterator over the (optionally oriented) boundary edges. More...

Public Types

using PointType = PointType_
using NumberType = PointType::NumberType
using LabelType = TLabel
template<bool Oriented>
using BoundaryType = std::conditional_t<Oriented, OrientedSegment<PointType>, Segment<PointType>>
using EdgeIterator = BoundaryIterator<false>
using OrientedEdgeIterator = BoundaryIterator<true>

Public Member Functions

constexpr Convex ()=default
 Creates a convex 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 Convex (Range &&points, bool trusted=false)
 Creates a convex from a range of points.
constexpr Convex (std::initializer_list< NumberType > coords, bool trusted=false)
 Creates a convex from a flat list of coordinates.
template<PointConcept OtherPointType, class OtherLabelType>
requires (std::constructible_from<PointType, const OtherPointType&>)
constexpr Convex (const Convex< OtherPointType, OtherLabelType > &other)
 Converts a convex with compatible vertex type.
template<class A = LabelType>
requires (detail::has_label_v<A>)
constexpr A & label () const
 Returns the convex-polygon label.
constexpr const PointType operator[] (std::size_t index) const
 Accesses a vertex by index.
constexpr PointType get (std::ptrdiff_t index) const
 Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end. Useful for iterating polygon edges where the last edge wraps around.
constexpr auto begin () const
 Returns a constant iterator to the beginning of vertices.
constexpr auto cbegin () const
 Returns a constant iterator to the beginning of vertices.
constexpr auto end () const
 Returns a constant iterator to the end of vertices.
constexpr auto cend () const
 Returns a constant iterator to the end of vertices.
constexpr auto operator<=> (const Convex &other) const
 Compares two convex polygons.
constexpr bool operator== (const Convex &other) const
 Checks equality of two convex polygons.
template<AnyShapeConcept OtherShape>
constexpr bool samePointSet (const OtherShape &other) const
 Tests whether another shape defines exactly the same point set.
constexpr auto twiceArea () const
 Computes twice the area of the convex polygon.
template<class ResultNumber = division_result_t<NumberType>>
constexpr auto area () const
 Computes the area of the convex polygon.
constexpr bool empty () const
 Returns whether the convex polygon is the empty set of points.
constexpr bool isDegenerate () const
 Checks if the convex polygon is degenerate (has zero area).
constexpr bool isPoint () const
 Returns whether the convex polygon collapses to a single point.
constexpr std::optional< PointTypegetIfPoint () const
 Returns the point the convex polygon collapses to, if it does.
constexpr bool isSegment () const
 Returns whether the convex polygon collapses to a non-degenerate segment.
constexpr std::optional< BoundaryType< false > > getIfSegment () const
 Returns the segment the convex polygon collapses to, if it does.
constexpr bool isUndefined () const
 Returns whether the convex polygon is degenerate without collapsing to a point or to a segment.
constexpr const Rectangle< PointType > & bbox () const
 Computes the bounding box of the convex polygon.
template<class ResultNumber = grid_number_t<typename PointType_::NumberType>>
requires (detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints () const
 Returns the integer points the convex polygon contains.
template<std::floating_point ResultNumber = double>
constexpr Rectangle< Point< ResultNumber > > fbox () const
 Computes the floating-point bounding box of the convex polygon.
constexpr const std::vector< PointTypevertices () const
 Returns the vertices of the convex polygon.
constexpr Convex< PointTypeconvexHull () const
 Returns the convex hull of the polygon's vertices.
constexpr std::vector< Segment< PointType > > edges () const
 Returns the edges of the convex polygon.
constexpr std::vector< OrientedSegment< PointType > > orientedEdges () const
 Returns the oriented edges of the convex polygon.
constexpr auto verticesView () const
 Returns a lazy view over the vertices, translating each on the fly instead of allocating a vector.
constexpr auto edgesView () const
 Returns a lazy view over the edges, materializing each Segment on the fly instead of allocating a vector.
constexpr auto orientedEdgesView () const
 Lazy view counterpart of orientedEdges(); see edgesView().
constexpr EdgeIterator edgesBegin () const
 Returns an iterator to the first unoriented edge.
constexpr EdgeIterator edgesEnd () const
 Returns an iterator past the last unoriented edge.
constexpr OrientedEdgeIterator orientedEdgesBegin () const
 Returns an iterator to the first oriented edge.
constexpr OrientedEdgeIterator orientedEdgesEnd () const
 Returns an iterator past the last oriented edge.
constexpr operator Polygon< PointType > () const
 Converts the convex polygon to a simple polygon.
constexpr Polygon< PointTypeasPolygon () const
 Returns the convex polygon as a simple polygon.
constexpr PolygonWithHoles< PointTypeasPolygonWithHoles () const
 Returns the convex polygon as a hole-free region.
constexpr PolygonSet< PointTypeasPolygonSet () const
 Returns the convex polygon as a one-component set of regions.
constexpr HalfplaneIntersection< PointTypeasHalfplaneIntersection () const
 Returns the convex polygon as a half-plane intersection.
constexpr MonotoneChain< PointTypelowerHull () const
 Returns the lower hull: the boundary chain running from the lexicographically smallest vertex to the lexicographically largest one, counterclockwise (below the polygon).
constexpr MonotoneChain< PointTypeupperHull () const
 Returns the upper hull: the boundary chain running from the lexicographically smallest vertex to the lexicographically largest one, clockwise (above the polygon).
template<PointConcept OtherPoint>
requires (!detail::is_point_v<TShape> && requires(const TShape& shape) { shape.vertices(); })
constexpr void insert (const OtherPoint &point)
 Enlarges the convex polygon so that it contains the given point.
template<class TShape>
requires (!detail::is_point_v<TShape> && requires(const TShape& shape) { shape.vertices(); })
constexpr void insert (const TShape &shape)
 Enlarges the convex polygon so that it contains a finite shape.
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> && (!requires(const
std::remove_cvref_t<Range>& shape) { shape.vertices(); })
constexpr void insert (Range &&range)
 Enlarges the convex polygon so that it contains every point in a range.
template<class ResultNumber = division_result_t<NumberType>>
constexpr Point< ResultNumber > centroid () const
 Computes the centroid of the convex polygon.
template<class ResultNumber = division_result_t<NumberType>>
constexpr Point< ResultNumber > verticesCentroid () const
 Computes the centroid of the vertex set.
template<class ResultNumber = division_result_t<NumberType>>
constexpr Point< ResultNumber > pointInside () const
 Returns a point inside the convex polygon.
template<class OtherShape>
constexpr bool pointInsideInteriorContainedIn (const OtherShape &shape) const
 Tests whether some point in this shape's relative interior lies in the strict interior of shape.
size_t size () const
 Returns the number of vertices in the convex polygon.
constexpr size_t maxIndex () const
 Returns the index of the maximum vertex (rightmost and highest in case of ties).
template<PointConcept OtherPoint>
constexpr bool verticesContain (const OtherPoint &point) const
 Checks if the vertices list contains the given point.
constexpr std::ptrdiff_t index (const PointType &point) const
 Returns the smallest index i with (*this)[i] == point, or -1 if point is not a vertex.
constexpr std::vector< std::pair< std::size_t, std::size_t > > antipodalPairs () const
 Returns every antipodal vertex-index pair, via rotating calipers.
constexpr Segment< PointTypediameter () const
 Returns a segment realizing the diameter (the farthest vertex pair).
constexpr HalfplaneIntersection< PointTypesmallestEnclosingRectangle () const
 Returns the smallest-area rectangle containing the convex polygon.
constexpr HalfplaneIntersection< PointTypesmallestEnclosingSlab () const
 Returns the narrowest slab containing the convex polygon.
template<class ResultNumber = division_result_t<NumberType>>
constexpr ResultNumber squaredMinimumWidth () const
 Returns the squared minimum width of the convex polygon.
template<class ApproximateNumber = double>
ApproximateNumber minimumWidth () const
 Returns the minimum width of the convex polygon.
template<class UniformRandomBitGenerator>
Disk< Point< NumberType > > smallestEnclosingDisk (UniformRandomBitGenerator &&generator) const
 Returns the smallest closed disk containing the convex polygon.
Disk< Point< NumberType > > smallestEnclosingDisk () const
 Returns the smallest closed disk containing the convex polygon.
template<PointConcept OtherPoint>
constexpr bool boundaryContains (const OtherPoint &point) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<SegmentConcept OtherSegment>
constexpr bool boundaryContains (const OtherSegment &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<OrientedSegmentConcept OtherOrientedSegment>
constexpr bool boundaryContains (const OtherOrientedSegment &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<LineConcept OtherLine>
constexpr bool boundaryContains (const OtherLine &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool boundaryContains (const OtherOrientedLine &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<RayConcept OtherRay>
constexpr bool boundaryContains (const OtherRay &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<HalfplaneConcept OtherHalfplane>
constexpr bool boundaryContains (const OtherHalfplane &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<RectangleConcept OtherRectangle>
constexpr bool boundaryContains (const OtherRectangle &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<TriangleConcept OtherTriangle>
constexpr bool boundaryContains (const OtherTriangle &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<ConvexConcept OtherConvex>
constexpr bool boundaryContains (const OtherConvex &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<PolygonConcept OtherPolygon>
constexpr bool boundaryContains (const OtherPolygon &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<DiskConcept OtherDisk>
constexpr bool boundaryContains (const OtherDisk &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<PointConcept OtherPoint>
constexpr bool boundaryContains (const Shape< OtherPoint > &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<class OtherNumberType>
constexpr std::optional< std::array< Segment< PointType >, 2 > > edgesAtX (OtherNumberType x) const
 Returns two edges of the convex polygon that intersect with the vertical line at x.
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 &) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool contains (const OtherOrientedLine &) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<RayConcept OtherRay>
constexpr bool contains (const OtherRay &) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<HalfplaneConcept OtherHalfplane>
constexpr bool contains (const OtherHalfplane &) 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<PointConcept OtherPoint>
constexpr bool contains (const Shape< OtherPoint > &other) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<class EmptyPoint>
constexpr bool contains (const EmptyShape< EmptyPoint > &) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<class EmptyPoint>
constexpr bool boundaryContains (const EmptyShape< EmptyPoint > &) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<class EmptyPoint>
constexpr bool interiorContains (const EmptyShape< EmptyPoint > &) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<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 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 &) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool interiorContains (const OtherOrientedLine &) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<RayConcept OtherRay>
constexpr bool interiorContains (const OtherRay &) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<HalfplaneConcept OtherHalfplane>
constexpr bool interiorContains (const OtherHalfplane &) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<RectangleConcept OtherRectangle>
constexpr bool interiorContains (const OtherRectangle &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<TriangleConcept OtherTriangle>
constexpr bool interiorContains (const OtherTriangle &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<ConvexConcept OtherConvex>
constexpr bool interiorContains (const OtherConvex &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<PolygonConcept OtherPolygon>
constexpr bool interiorContains (const OtherPolygon &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<DiskConcept OtherDisk>
constexpr bool interiorContains (const OtherDisk &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<PointConcept OtherPoint>
constexpr bool interiorContains (const Shape< OtherPoint > &other) const
 Tests whether this shape's interior contains the other shape (A∖∂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<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<PointConcept OtherPoint>
constexpr bool intersects (const OtherPoint &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<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<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<Convex>)
constexpr bool intersects (const OtherShape &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 interiorsIntersect (const OtherPoint &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<LineConcept OtherLine>
constexpr bool interiorsIntersect (const OtherLine &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<OrientedLineConcept OtherOrientedLine>
constexpr bool interiorsIntersect (const OtherOrientedLine &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<SegmentConcept OtherSegment>
constexpr bool interiorsIntersect (const OtherSegment &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<OrientedSegmentConcept OtherOrientedSegment>
constexpr bool interiorsIntersect (const OtherOrientedSegment &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<RayConcept OtherRay>
constexpr bool interiorsIntersect (const OtherRay &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<HalfplaneConcept OtherHalfplane>
constexpr bool interiorsIntersect (const OtherHalfplane &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<RectangleConcept OtherRectangle>
constexpr bool interiorsIntersect (const OtherRectangle &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<TriangleConcept OtherTriangle>
constexpr bool interiorsIntersect (const OtherTriangle &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<ConvexConcept OtherConvex>
constexpr bool interiorsIntersect (const OtherConvex &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<DiskConcept OtherDisk>
constexpr bool interiorsIntersect (const OtherDisk &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<PointConcept OtherPoint>
constexpr bool interiorsIntersect (const Shape< OtherPoint > &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<typename OtherShape>
requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Convex>)
constexpr bool interiorsIntersect (const OtherShape &other) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
template<class EmptyPoint>
constexpr bool interiorsIntersect (const EmptyShape< EmptyPoint > &) const
 Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂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 &) 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<ConvexConcept OtherConvex>
constexpr bool separates (const OtherConvex &other) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
template<PolygonConcept OtherPolygon>
constexpr bool separates (const OtherPolygon &other) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
template<MonotoneChainConcept OtherChain>
constexpr bool contains (const OtherChain &other) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<MonotoneChainConcept OtherChain>
constexpr bool boundaryContains (const OtherChain &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<MonotoneChainConcept OtherChain>
constexpr bool interiorContains (const OtherChain &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<MonotoneChainConcept OtherChain>
constexpr bool separates (const OtherChain &other) const
 Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
template<PolylineConcept OtherPolyline>
constexpr bool contains (const OtherPolyline &other) const
 Tests whether this shape contains the other shape (A ⊇ B).
template<PolylineConcept OtherPolyline>
constexpr bool boundaryContains (const OtherPolyline &other) const
 Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
template<PolylineConcept OtherPolyline>
constexpr bool interiorContains (const OtherPolyline &other) const
 Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
template<PolylineConcept OtherPolyline>
constexpr bool 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<DiskConcept OtherDisk>
constexpr bool separates (const OtherDisk &other) 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 &) 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<ConvexConcept OtherConvex>
constexpr bool crosses (const OtherConvex &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<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<Convex>)
constexpr bool crosses (const OtherShape &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<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>, 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>, 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>, 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>, 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 = double, DiskConcept OtherDisk>
detail::floating_result_t< ResultNumber > squaredDistance (const OtherDisk &other) const
 Returns the squared Euclidean distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& 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<Convex<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<Convex<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>, 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>, 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>, 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>, 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>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template distanceL1<ResultNumber>(self); })
constexpr auto distanceL1 (const OtherShape &other) const
 Returns the Manhattan (L1) distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
constexpr auto intersection (const Shape< OtherPoint > &other) const
 Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersection.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto regularizedIntersection (const Shape< OtherPoint > &other) const
 Re-dispatches a regularized intersection through a runtime shape.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto regularizedUnion (const Shape< OtherPoint > &other) const
 Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own regularizedUnion.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto difference (const Shape< OtherPoint > &other) const
 Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper's own difference.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto symmetricDifference (const Shape< OtherPoint > &other) const
 Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wrapper's own symmetricDifference.
template<class ResultNumber = double, PointConcept OtherPoint>
constexpr auto distanceL1 (const Shape< OtherPoint > &other) const
 Returns the Manhattan (L1) distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
constexpr auto distanceLInf (const OtherPoint &point) const
 Returns the Chebyshev (LInf) distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
constexpr auto distanceLInf (const OtherSegment &other) const
 Returns the Chebyshev (LInf) distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
constexpr auto distanceLInf (const OtherOrientedSegment &other) const
 Returns the Chebyshev (LInf) distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, 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>, 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>, 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>, 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>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template distanceLInf<ResultNumber>(self); })
constexpr auto distanceLInf (const OtherShape &other) const
 Returns the Chebyshev (LInf) distance to the given shape.
template<class ResultNumber = double, PointConcept OtherPoint>
constexpr auto distanceLInf (const Shape< OtherPoint > &other) const
 Returns the Manhattan (L1) distance to the given shape.
template<class ResultNumber = NumberType, PointConcept OtherPoint>
constexpr auto hausdorffDistanceL1 (const OtherPoint &point) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
constexpr auto hausdorffDistanceL1 (const OtherSegment &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
constexpr auto hausdorffDistanceL1 (const OtherOrientedSegment &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
constexpr auto hausdorffDistanceL1 (const OtherRectangle &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
constexpr auto hausdorffDistanceL1 (const OtherTriangle &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
constexpr auto hausdorffDistanceL1 (const OtherConvex &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template hausdorffDistanceL1<ResultNumber>(self); })
constexpr auto hausdorffDistanceL1 (const OtherShape &other) const
 Returns the Manhattan (L1) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
constexpr auto hausdorffDistanceL1 (const Shape< OtherPoint > &other) const
 Returns the Manhattan (L1) distance to the given shape.
template<class ResultNumber = NumberType, PointConcept OtherPoint>
constexpr auto hausdorffDistanceLInf (const OtherPoint &point) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
constexpr auto hausdorffDistanceLInf (const OtherSegment &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
constexpr auto hausdorffDistanceLInf (const OtherOrientedSegment &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
constexpr auto hausdorffDistanceLInf (const OtherRectangle &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
constexpr auto hausdorffDistanceLInf (const OtherTriangle &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
constexpr auto hausdorffDistanceLInf (const OtherConvex &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template hausdorffDistanceLInf<ResultNumber>(self); })
constexpr auto hausdorffDistanceLInf (const OtherShape &other) const
 Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
constexpr auto hausdorffDistanceLInf (const Shape< OtherPoint > &other) const
 Returns the Manhattan (L1) distance to the given shape.
template<class ResultNumber = NumberType, PointConcept OtherPoint>
constexpr auto squaredHausdorffDistance (const OtherPoint &point) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
constexpr auto squaredHausdorffDistance (const OtherSegment &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
constexpr auto squaredHausdorffDistance (const OtherOrientedSegment &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
constexpr auto squaredHausdorffDistance (const OtherRectangle &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
constexpr auto squaredHausdorffDistance (const OtherTriangle &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
constexpr auto squaredHausdorffDistance (const OtherConvex &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template squaredHausdorffDistance<ResultNumber>(self); })
constexpr auto squaredHausdorffDistance (const OtherShape &other) const
 Returns the squared Hausdorff distance to the given shape.
template<class ResultNumber = NumberType, PointConcept OtherPoint>
constexpr std::optional< Point< ResultNumber, typename PointType::LabelType > > intersection (const OtherPoint &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherSegment &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherOrientedSegment &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherLine &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherOrientedLine &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherRay &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherHalfplane &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = NumberType, HalfplaneIntersectionConcept OtherRegion>
constexpr auto intersection (const OtherRegion &other) const
 Adds this convex polygon's constraints to a half-plane intersection without deriving vertices.
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherRectangle &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherTriangle &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
constexpr std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > intersection (const OtherConvex &other) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!PointConcept<OtherShape> && !HalfplaneIntersectionConcept<OtherShape> && (detail::shapeRank<OtherShape>
> detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& 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 = division_result_t<NumberType>, typename OtherShape>
requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape&
o, const Convex& self) { o.template regularizedIntersection<ResultNumber>(self); })
constexpr auto regularizedIntersection (const OtherShape &other) const
 Forwards a regularized intersection to the shape that owns it.
template<class ResultNumber = NumberType, class EmptyPoint>
constexpr EmptyShape< EmptyPoint > intersection (const EmptyShape< EmptyPoint > &) const
 Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr Convex rotated90 (int k=1) const
 Returns the convex polygon rotated by 90k degrees around the origin.
constexpr void rotate90 (int k=1)
 Rotates the convex polygon by 90k degrees around the origin in place.
template<class OtherNumber>
constexpr Convex scaledUpX (const OtherNumber scalar) const
 Returns the convex polygon with its x-coordinates multiplied by a factor.
template<class OtherNumber>
constexpr void scaleUpX (const OtherNumber scalar)
 Multiplies the convex polygon's x-coordinates by a factor in place.
template<class OtherNumber>
constexpr Convex scaledUpY (const OtherNumber scalar) const
 Returns the convex polygon with its y-coordinates multiplied by a factor.
template<class OtherNumber>
constexpr void scaleUpY (const OtherNumber scalar)
 Multiplies the convex polygon's y-coordinates by a factor in place.
template<class OtherNumber>
constexpr Convex scaledDownX (const OtherNumber scalar) const
 Returns the convex polygon with its x-coordinates divided by a divisor.
template<class OtherNumber>
constexpr void scaleDownX (const OtherNumber scalar)
 Divides the convex polygon's x-coordinates by a divisor in place.
template<class OtherNumber>
constexpr Convex scaledDownY (const OtherNumber scalar) const
 Returns the convex polygon with its y-coordinates divided by a divisor.
template<class OtherNumber>
constexpr void scaleDownY (const OtherNumber scalar)
 Divides the convex polygon's y-coordinates by a divisor in place.
template<class OtherShape>
requires MinkowskiSummableConcept<Convex<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<Convex<PointType_, TLabel>, OtherShape>
constexpr auto minkowskiErosion (const OtherShape &other) const
 Returns the Minkowski erosion of this shape by another (A ⊖ B).
template<class OtherShape>
requires (!MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape> && BoundedPolygonalConcept<OtherShape>)
constexpr auto minkowskiErosion (const OtherShape &other) const
 Returns the Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B).
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank
<Convex>) && requires(const OtherShape& o, const Convex& self) { o.template minkowskiSum<ResultNumber>(self); })
auto minkowskiSum (const OtherShape &other) const
 Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion (const OtherConvex &other) const
 Returns the regularized union of the two shapes (A ∪ B).
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion (const OtherTriangle &other) const
 Returns the regularized union of the two shapes (A ∪ B).
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion (const OtherRectangle &other) const
 Returns the regularized union of the two shapes (A ∪ B).
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template regularizedUnion<ResultNumber>(self); })
auto regularizedUnion (const OtherShape &other) const
 Returns the regularized union of the two shapes (A ∪ B).
template<class ResultNumber = division_result_t<NumberType>, PolygonalRegionConcept OtherRegion>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference (const OtherRegion &other) const
 Returns the regularized set difference of the two shapes (A ∖ B).
template<class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference (const OtherIntersection &other) const
 Returns the regularized set difference of the two shapes (A ∖ B).
template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference (const OtherHalfplane &other) const
 Returns the regularized set difference of the two shapes (A ∖ B).
template<class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference (const OtherConvex &other) const
 Returns the regularized symmetric difference of the two shapes (A △ B).
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference (const OtherTriangle &other) const
 Returns the regularized symmetric difference of the two shapes (A △ B).
template<class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference (const OtherRectangle &other) const
 Returns the regularized symmetric difference of the two shapes (A △ B).
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template symmetricDifference<ResultNumber>(self); })
auto symmetricDifference (const OtherShape &other) const
 Returns the regularized symmetric difference of the two shapes (A △ B).
template<PointConcept OtherPoint>
constexpr Convexoperator+= (const OtherPoint &translation)
 Translates the convex polygon by the given point in place.
template<PointConcept OtherPoint>
constexpr Convexoperator-= (const OtherPoint &translation)
 Translates the convex polygon by the negation of the given point.
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Convexoperator*= (const Scalar &scalar)
 Scales the convex polygon by the given scalar.
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Convexoperator/= (const Scalar &scalar)
 Divides the convex polygon by the given scalar.
template<class UniformRandomBitGenerator>
Disk< Point< typename Convex< PointType, LabelType >::NumberType > > smallestEnclosingDisk (UniformRandomBitGenerator &&generator) const
template<class ResultNumber, PolygonalRegionConcept OtherRegion>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > difference (const OtherRegion &other) const
template<class ResultNumber, HalfplaneIntersectionConcept OtherIntersection>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > difference (const OtherIntersection &other) const
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > difference (const OtherHalfplane &other) const
template<class ResultNumber, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > regularizedUnion (const OtherConvex &other) const
template<class ResultNumber, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > regularizedUnion (const OtherTriangle &other) const
template<class ResultNumber, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > regularizedUnion (const OtherRectangle &other) const
template<class ResultNumber, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > symmetricDifference (const OtherConvex &other) const
template<class ResultNumber, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > symmetricDifference (const OtherTriangle &other) const
template<class ResultNumber, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > symmetricDifference (const OtherRectangle &other) const
template<PointConcept OtherPoint>
constexpr Convex< PointType, LabelType > & operator+= (const OtherPoint &translation)
template<PointConcept OtherPoint>
constexpr Convex< PointType, LabelType > & operator-= (const OtherPoint &translation)
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Convex< PointType, LabelType > & operator*= (const Scalar &scalar)
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
constexpr Convex< PointType, LabelType > & operator/= (const Scalar &scalar)
template<class OtherNumber>
constexpr Convex< PointType, LabelTypescaledUpX (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Convex< PointType, LabelTypescaledUpY (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Convex< PointType, LabelTypescaledDownX (const OtherNumber scalar) const
template<class OtherNumber>
constexpr Convex< PointType, LabelTypescaledDownY (const OtherNumber scalar) const

Detailed Description

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

Closed convex polygon stored by its vertices.

Member Typedef Documentation

◆ BoundaryType

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

◆ EdgeIterator

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

◆ LabelType

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

◆ NumberType

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

◆ OrientedEdgeIterator

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

◆ PointType

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

Constructor & Destructor Documentation

◆ Convex() [1/4]

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

Creates a convex with no vertex.

◆ Convex() [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::Convex< PointType_, TLabel >::Convex ( Range && points,
bool trusted = false )
inlineexplicitconstexpr

Creates a convex from a range of points.

Template Parameters
RangeInput range whose elements can be converted to PointType.
Parameters
pointsRange of points to enclose.
trustedSet to true if the points are already convex hull vertices starting from the leftmost and ccw.

◆ Convex() [3/4]

template<class PointType_, class TLabel>
pgl::Convex< PointType_, TLabel >::Convex ( std::initializer_list< NumberType > coords,
bool trusted = false )
inlineexplicitconstexpr

Creates a convex from a flat list of coordinates.

The values are consumed in pairs (x0, y0, x1, y1, …), each pair forming one point, so the list must hold an even number of values.

Parameters
coordsInterleaved x/y coordinates of the points to enclose.
trustedSet to true if the points are already convex hull vertices starting from the leftmost and ccw.

◆ Convex() [4/4]

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

Converts a convex with compatible vertex type.

Template Parameters
OtherPointTypeSource vertex type.
Parameters
otherSource convex.

Member Function Documentation

◆ antipodalPairs()

template<class PointType, class LabelType>
std::vector< std::pair< std::size_t, std::size_t > > pgl::Convex< PointType, LabelType >::antipodalPairs ( ) const
constexpr

Returns every antipodal vertex-index pair, via rotating calipers.

A pair of vertices is antipodal when the polygon admits two parallel supporting lines, one through each vertex. The pairs are produced with a single rotating-calipers sweep over the CCW boundary. Each unordered pair is reported once as {i, j} with i < j, where the indices refer to the CCW vertex order exposed by operator[]. A convex polygon has at most 3n/2 antipodal pairs.

Complexity: O(n) for n vertices.

Returns
Vector of antipodal index pairs (empty for fewer than two vertices).

◆ area()

template<class PointType, class LabelType>
template<class ResultNumber>
auto pgl::Convex< PointType, LabelType >::area ( ) const
constexpr

Computes the area of the convex polygon.

Returns
The area of the convex polygon.
Warning
Uses division by 2.

◆ asHalfplaneIntersection()

template<class PointType_, class TLabel>
HalfplaneIntersection< PointType > pgl::Convex< PointType_, TLabel >::asHalfplaneIntersection ( ) const
inlinenodiscardconstexpr

Returns the convex polygon as a half-plane intersection.

The region is the intersection of the edge half-planes. An empty polygon produces the empty region; a degenerate one (a point or a segment) produces the corresponding degenerate region.

Returns
Half-plane intersection whose point set is this convex polygon.

◆ asPolygon()

template<class PointType_, class TLabel>
Polygon< PointType > pgl::Convex< PointType_, TLabel >::asPolygon ( ) const
inlinenodiscardconstexpr

Returns the convex polygon as a simple polygon.

Returns
Polygon with the same vertices.

◆ asPolygonSet()

template<class PointType_, class TLabel>
PolygonSet< PointType > pgl::Convex< PointType_, TLabel >::asPolygonSet ( ) const
inlinenodiscardconstexpr

Returns the convex polygon as a one-component set of regions.

A convex polygon with no area covers nothing that survives regularization, so it gives back the empty set rather than a component without area.

Returns
PolygonSet whose only component is the convex polygon as a region.

◆ asPolygonWithHoles()

template<class PointType_, class TLabel>
PolygonWithHoles< PointType > pgl::Convex< PointType_, TLabel >::asPolygonWithHoles ( ) const
inlinenodiscardconstexpr

Returns the convex polygon as a hole-free region.

Returns
PolygonWithHoles whose outer boundary is the convex polygon and which has no holes.

◆ bbox()

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

Computes the bounding box of the convex polygon.

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

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

Returns
A constant reference to the rectangle representing the bounding box.

◆ begin()

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

Returns a constant iterator to the beginning of vertices.

Returns
Constant iterator to the first vertex.

◆ boundaryContains() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Convex< 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 LabelType>
template<MonotoneChainConcept OtherChain>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherChain & other) const
nodiscardconstexpr

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

◆ boundaryContains() [3/19]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Returns false unless the convex polygon has at most two vertices. Complexity: O(log n) for n vertices on this convex polygon.

◆ boundaryContains() [4/19]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherDisk & other) const
constexpr

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

Returns false unless all disk points are the same and that point is on the boundary of this convex polygon. Complexity: O(log n) for n vertices on this convex polygon.

◆ boundaryContains() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherHalfplane & other) const
constexpr

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

Complexity: O(log n) for n vertices.

◆ boundaryContains() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherLine & other) const
constexpr

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

Complexity: O(log n) for n vertices.

◆ boundaryContains() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherOrientedLine & other) const
constexpr

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

Complexity: O(log n) for n vertices.

◆ boundaryContains() [8/19]

template<class PointType, class LabelType>
template<OrientedSegmentConcept OtherOrientedSegment>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherOrientedSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

◆ boundaryContains() [9/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type to check.
Parameters
pointThe point to check.
Returns
True if the point is on the boundary, false otherwise.

◆ boundaryContains() [10/19]

template<class PointType, class LabelType>
template<PolygonConcept OtherPolygon>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherPolygon & other) const
constexpr

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

◆ boundaryContains() [11/19]

template<class PointType, class LabelType>
template<PolylineConcept OtherPolyline>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherPolyline & other) const
nodiscardconstexpr

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

◆ boundaryContains() [12/19]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherRay & other) const
constexpr

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

Complexity: O(log n) for n vertices.

◆ boundaryContains() [13/19]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherRectangle & other) const
constexpr

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

Complexity: O(log n) for n vertices (four edge checks).

◆ boundaryContains() [14/19]

template<class PointType_, class TLabel>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Convex< 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::Convex< 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 LabelType>
template<SegmentConcept OtherSegment>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Uses three O(log n) point-membership queries: both endpoints must lie on the boundary, and so must the midpoint. For a convex polygon, a segment with all three on the boundary necessarily lies on a single edge — otherwise it would be a chord passing through the interior.

Template Parameters
OtherPointThe point type of the segment.
Parameters
otherThe segment to check.
Returns
True if the segment lies on the convex polygon boundary.

◆ boundaryContains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Convex< 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 LabelType>
template<TriangleConcept OtherTriangle>
bool pgl::Convex< PointType, LabelType >::boundaryContains ( const OtherTriangle & other) const
constexpr

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

Complexity: O(log n) for n vertices (three edge checks).

◆ boundaryContains() [19/19]

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

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

◆ cbegin()

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

Returns a constant iterator to the beginning of vertices.

Returns
Constant iterator to the first vertex.

◆ cend()

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

Returns a constant iterator to the end of vertices.

Returns
Constant iterator past the last vertex.

◆ centroid()

template<class PointType, class LabelType>
template<class ResultNumber>
Point< ResultNumber > pgl::Convex< PointType, LabelType >::centroid ( ) const
constexpr

Computes the centroid of the convex polygon.

Template Parameters
ResultNumberThe number type for the result.
Returns
The centroid point.
Warning
Uses division by 3 and twice the area, so the result may be inexact even for floating-point types.

◆ closestPoints()

template<class PointType_, class TLabel>
requires detail::ClosestPointsPairConcept<Convex<PointType_, TLabel>, OtherShape>
template<class ResultNumber, class OtherShape>
requires detail::ClosestPointsPairConcept<Convex<PointType_, TLabel>, OtherShape>
auto pgl::Convex< 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<Convex<PointType_, TLabel>, OtherShape>
template<class ResultNumber, BoundedPolygonalConcept OtherShape>
requires detail::ClosestPairConcept<Convex<PointType_, TLabel>, OtherShape>
auto pgl::Convex< 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::Convex< 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::Convex< PointType, LabelType >::contains ( const OtherChain & other) const
nodiscardconstexpr

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

◆ contains() [3/19]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::contains ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Complexity: O(min(n,m) log (n+m)) for convex polygons with n and m vertices.

Template Parameters
OtherPointThe point type of the convex polygon.
Parameters
otherThe convex polygon to check.
Returns
True if the convex polygon contains the convex polygon, false otherwise.

◆ contains() [4/19]

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

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

Complexity: O(n) for n vertices on this convex polygon.

◆ contains() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Convex< PointType, LabelType >::contains ( const OtherHalfplane & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the halfplane.
Parameters
otherThe halfplane to check.
Returns
Always returns false since a halfplane cannot be fully contained in A convex polygon.

◆ contains() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Convex< PointType, LabelType >::contains ( const OtherLine & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the line.
Parameters
otherThe line to check.
Returns
Always returns false since a line cannot be fully contained in A convex polygon.

◆ contains() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Convex< PointType, LabelType >::contains ( const OtherOrientedLine & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the oriented line.
Parameters
otherThe oriented line to check.
Returns
Always returns false since an oriented line cannot be fully contained in A convex polygon.

◆ contains() [8/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the oriented segment.
Parameters
otherThe oriented segment to check.
Returns
True if the convex polygon contains the oriented segment, false otherwise.

◆ contains() [9/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type to check.
Parameters
pointThe point to check.
Returns
True if the point is on the boundary or inside the convex polygon, false otherwise.

◆ contains() [10/19]

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

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

◆ contains() [11/19]

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

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

◆ contains() [12/19]

template<class PointType, class LabelType>
template<RayConcept OtherRay>
bool pgl::Convex< PointType, LabelType >::contains ( const OtherRay & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the ray.
Parameters
otherThe ray to check.
Returns
Always returns false since a ray cannot be fully contained in A convex polygon.

◆ contains() [13/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the rectangle.
Parameters
otherThe rectangle to check.
Returns
True if the convex polygon contains the rectangle, false otherwise.

◆ contains() [14/19]

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

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

A region is contained exactly when its outer polygon is: the region holds the whole outer ring whatever its holes do, and this shape has a connected complement. See implementation/contains.hpp.

◆ contains() [15/19]

template<class PointType, class LabelType>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Convex< 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::Convex< PointType, LabelType >::contains ( const OtherSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the segment.
Parameters
otherThe segment to check.
Returns
True if the convex polygon contains the segment, false otherwise.

◆ contains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Convex< 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::Convex< PointType, LabelType >::contains ( const OtherTriangle & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the triangle.
Parameters
otherThe triangle to check.
Returns
True if the convex polygon contains the triangle, false otherwise.

◆ contains() [19/19]

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

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

◆ convexHull()

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

Returns the convex hull of the polygon's vertices.

A convex polygon is already its own hull, so this just drops the label.

◆ crosses() [1/14]

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

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

◆ crosses() [2/14]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::crosses ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Complexity: O(n log m + m log n) for this polygon with n vertices and the other with m vertices.

◆ crosses() [3/14]

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

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

Complexity: O(n) for n vertices on this convex polygon.

◆ crosses() [4/14]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Convex< PointType, LabelType >::crosses ( const OtherHalfplane & ) const
constexpr

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

Complexity: O(1).

◆ crosses() [5/14]

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

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

Complexity: O(log n) for n vertices.

◆ crosses() [6/14]

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

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

Complexity: O(log n) for n vertices.

◆ crosses() [7/14]

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

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

Complexity: O(log n) for n vertices.

◆ crosses() [8/14]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Convex< PointType, LabelType >::crosses ( const OtherPoint & ) const
constexpr

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

Complexity: O(1).

◆ crosses() [9/14]

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

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

Complexity: O(log n) for n vertices.

◆ crosses() [10/14]

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

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

Complexity: O(n) for n vertices, dominated by interiorsIntersect.

◆ crosses() [11/14]

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

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

Complexity: O(log n) for n vertices.

◆ crosses() [12/14]

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

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

◆ crosses() [13/14]

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

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

Complexity: O(n) for n vertices, dominated by interiorsIntersect.

◆ crosses() [14/14]

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

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

◆ diameter()

template<class PointType, class LabelType>
Segment< PointType > pgl::Convex< PointType, LabelType >::diameter ( ) const
constexpr

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

The farthest pair of vertices of a convex polygon is always antipodal, so the diameter is the longest segment over antipodalPairs(). Distances are compared exactly via squared length.

Complexity: O(n) for n vertices.

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

◆ difference() [1/7]

template<class PointType_, class TLabel>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherHalfplane & other) const

◆ difference() [2/7]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherHalfplane & other) const
nodiscard

Returns the regularized set difference of the two shapes (A ∖ B).

A half-plane is the one-constraint half-plane intersection, and is handled as one: see difference(const OtherIntersection&) const.

◆ difference() [3/7]

template<class PointType_, class TLabel>
template<class ResultNumber, HalfplaneIntersectionConcept OtherIntersection>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherIntersection & other) const

◆ difference() [4/7]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherIntersection & other) const
nodiscard

Returns the regularized set difference of the two shapes (A ∖ B).

A half-plane intersection may be unbounded, which stops it being a regularizedUnion operand but not a subtrahend: A ∖ B is bounded whenever A is, however far B reaches, so a PolygonSet can hold it. See PolygonWithHoles::difference(const OtherIntersection&) const for the clip that bounds it and for the rest of the contract.

◆ difference() [5/7]

template<class PointType_, class TLabel>
template<class ResultNumber, PolygonalRegionConcept OtherRegion>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherRegion & other) const

◆ difference() [6/7]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PolygonalRegionConcept OtherRegion>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Convex< PointType_, TLabel >::difference ( const OtherRegion & other) const
nodiscard

Returns the regularized set difference of the two shapes (A ∖ B).

A difference is not symmetric, so there is no higher-ranked operand to hand the pair to the way regularizedUnion does: a convex polygon has to state it against every region itself. It states it once, over all six of them, by going through its polygon spelling — the same conversion every other operation makes, and one that costs nothing, the vertices already being in canonical polygon order. See Polygon::difference for the contract.

Template Parameters
ResultNumberThe number type for the result.
Parameters
otherThe shape to remove.
Returns
The pieces of the difference, in canonical order.

◆ difference() [7/7]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::difference ( const Shape< OtherPoint > & other) const
inlinenodiscard

Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper's own difference.

A difference is not symmetric, so unlike regularizedUnion this cannot be handed to other as it stands. It wraps this shape instead and lets the wrapper visit both sides, which throws if the pair is unsupported — here, whenever other turns out to hold anything without area, or a Disk. An unbounded alternative is fine on this side, the result being contained in this shape either way. See Polygon::difference for the contract.

The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.

◆ distanceL1() [1/12]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::distanceL1 ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [2/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [3/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [4/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [5/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [6/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [7/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [8/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [9/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [10/12]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template distanceL1<ResultNumber>(self); })
auto pgl::Convex< 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 (the only shape ranked above Convex is Polygon).

◆ distanceL1() [11/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the L1 gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceL1() [12/12]

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

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

Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.

◆ distanceLInf() [1/12]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::distanceLInf ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [2/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [3/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [4/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [5/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [6/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [7/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [8/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [9/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [10/12]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template distanceLInf<ResultNumber>(self); })
auto pgl::Convex< 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 (the only shape ranked above Convex is Polygon).

◆ distanceLInf() [11/12]

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

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

Unlike squaredDistance, this always uses the O(n) edge scan (no cyclic support-function search): the LInf gauge is not linear along an edge normal the way the Euclidean squared distance is, so the fast path's search functional does not carry over.

◆ distanceLInf() [12/12]

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

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

Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.

◆ edges()

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

Returns the edges of the convex polygon.

Returns
A vector of segments representing the edges.

◆ edgesAtX()

template<class PointType, class LabelType>
template<class OtherNumberType>
std::optional< std::array< Segment< PointType >, 2 > > pgl::Convex< PointType, LabelType >::edgesAtX ( OtherNumberType x) const
constexpr

Returns two edges of the convex polygon that intersect with the vertical line at x.

If the vertical line at x does not intersect the polygon, then std::nullopt is returned. If the vertical line at x intersects the polygon, then it returns an edge of the strict upper convex boundary and an edge of the strict lower convex boundary. By strict I mean that the edges returned are not vertical. If the intersection happens at a vertex between two non-vertical esges, then either one may be returned.

Complexity: O(log n) for n vertices.

Parameters
xThe x-coordinate of the vertical line.
Returns
An optional array containing the intersecting edges, or std::nullopt if none.

◆ edgesBegin()

template<class PointType_, class TLabel>
EdgeIterator pgl::Convex< 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::Convex< 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::Convex< 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() (including the closing edge back to vertex 0) 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::Convex< PointType_, TLabel >::empty ( ) const
inlinenodiscardconstexpr

Returns whether the convex polygon is the empty set of points.

A convex polygon with no vertices covers nothing, which is the state of a default-constructed one, of the hull of no points, and of every convex-valued result that comes back empty. It behaves as EmptyShape: every predicate reads it as the empty set.

Complexity: O(1).

Returns
true if the convex polygon covers no point.

◆ end()

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

Returns a constant iterator to the end of vertices.

Returns
Constant iterator past the last vertex.

◆ fbox()

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

Computes the floating-point bounding box of the convex polygon.

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

◆ get()

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

Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end. Useful for iterating polygon edges where the last edge wraps around.

◆ getIfPoint()

template<class PointType, class LabelType>
std::optional< PointType > pgl::Convex< PointType, LabelType >::getIfPoint ( ) const
nodiscardconstexpr

Returns the point the convex polygon collapses to, if it does.

Complexity: O(1).

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

◆ getIfSegment()

template<class PointType, class LabelType>
std::optional< typename Convex< PointType, LabelType >::template BoundaryType< false > > pgl::Convex< PointType, LabelType >::getIfSegment ( ) const
nodiscardconstexpr

Returns the segment the convex polygon collapses to, if it does.

Complexity: O(1).

Returns
The segment between the two vertices if isSegment, std::nullopt otherwise.

◆ hausdorffDistanceL1() [1/8]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [2/8]

template<class PointType_, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherOrientedSegment & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [3/8]

template<class PointType_, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherPoint & point) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [4/8]

template<class PointType_, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherRectangle & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [5/8]

template<class PointType_, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherSegment & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [6/8]

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

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

Forwards to the other shape's implementation so that each unordered pair needs hausdorffDistanceL1 defined only once, on the higher-ranked shape (the only shape ranked above Convex is Polygon).

◆ hausdorffDistanceL1() [7/8]

template<class PointType_, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceL1 ( const OtherTriangle & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceL1() [8/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::hausdorffDistanceL1 ( const Shape< OtherPoint > & other) const
inlinenodiscardconstexpr

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

Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.

◆ hausdorffDistanceLInf() [1/8]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [2/8]

template<class PointType_, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherOrientedSegment & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [3/8]

template<class PointType_, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherPoint & point) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [4/8]

template<class PointType_, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherRectangle & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [5/8]

template<class PointType_, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherSegment & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [6/8]

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

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

Forwards to the other shape's implementation so that each unordered pair needs hausdorffDistanceLInf defined only once, on the higher-ranked shape (the only shape ranked above Convex is Polygon).

◆ hausdorffDistanceLInf() [7/8]

template<class PointType_, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Convex< PointType_, LabelType >::hausdorffDistanceLInf ( const OtherTriangle & other) const
nodiscardconstexpr

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

◆ hausdorffDistanceLInf() [8/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::hausdorffDistanceLInf ( const Shape< OtherPoint > & other) const
inlinenodiscardconstexpr

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

Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.

◆ index()

template<class PointType, class LabelType>
std::ptrdiff_t pgl::Convex< PointType, LabelType >::index ( const PointType & point) const
constexpr

Returns the smallest index i with (*this)[i] == point, or -1 if point is not a vertex.

Complexity: O(log n) for n vertices, via binary search over the two monotone boundary chains (mirrors verticesContain).

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

◆ insert() [1/3]

template<class PointType, class LabelType>
requires (!detail::is_point_v<TShape> && requires(const TShape& shape) { shape.vertices(); })
template<class TShape>
requires (!detail::is_point_v<TShape> && requires(const TShape& shape) { shape.vertices(); })
void pgl::Convex< PointType, LabelType >::insert ( const TShape & point)
constexpr

Enlarges the convex polygon so that it contains the given point.

Complexity: O(log n) when the point is already contained, O(n log n) otherwise, for n vertices.

Template Parameters
OtherPointType of the point.
Parameters
pointPoint to insert.

◆ insert() [2/3]

template<class PointType_, class TLabel>
template<class TShape>
requires (!detail::is_point_v<TShape> && requires(const TShape& shape) { shape.vertices(); })
void pgl::Convex< PointType_, TLabel >::insert ( const TShape & shape)
constexpr

Enlarges the convex polygon so that it contains a finite shape.

The shape must expose vertices() — its convex hull is then the hull of those vertices. Shapes without vertices (disks) and infinite shapes (lines, rays, halfplanes) are intentionally not accepted.

Complexity: O((n + k) log(n + k)) for n vertices and a shape with k vertices.

Template Parameters
TShapeShape type exposing vertices().
Parameters
shapeShape to insert.

◆ insert() [3/3]

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> && (!requires(const
std::remove_cvref_t<Range>& shape) { shape.vertices(); })
void pgl::Convex< PointType_, TLabel >::insert ( Range && range)
inlineconstexpr

Enlarges the convex polygon so that it contains every point in a range.

A shape (which exposes vertices()) is handled by the shape overload, even though it may itself be iterable as a range of points.

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

Template Parameters
RangeRange of points.
Parameters
rangePoints to insert.

◆ interiorContains() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Convex< 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::Convex< 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 LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Complexity: O(min(n,m) log (m+n)) for polygons with n and m vertices

Template Parameters
OtherPointThe point type of the convex polygon.
Parameters
otherThe convex polygon to check.
Returns
True if the interior of the convex polygon contains the convex polygon, false otherwise.

◆ interiorContains() [4/19]

template<class PointType, class LabelType>
template<DiskConcept OtherDisk>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherDisk & other) const
constexpr

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

Complexity: O(n) for n vertices on this convex polygon.

◆ interiorContains() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherHalfplane & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the halfplane.
Parameters
otherThe halfplane to check.
Returns
Always returns false since a halfplane cannot be fully contained in A convex polygon.

◆ interiorContains() [6/19]

template<class PointType, class LabelType>
template<LineConcept OtherLine>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherLine & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the line.
Parameters
otherThe line to check.
Returns
Always returns false since a line cannot be fully contained in A convex polygon.

◆ interiorContains() [7/19]

template<class PointType, class LabelType>
template<OrientedLineConcept OtherOrientedLine>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherOrientedLine & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the oriented line.
Parameters
otherThe oriented line to check.
Returns
Always returns false since an oriented line cannot be fully contained in A convex polygon.

◆ interiorContains() [8/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the oriented segment.
Parameters
otherThe oriented segment to check.
Returns
True if the interior of the convex polygon contains the oriented segment, false otherwise.

◆ interiorContains() [9/19]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type to check.
Parameters
pointThe point to check.
Returns
True if the point is strictly inside the convex polygon, false otherwise.

◆ interiorContains() [10/19]

template<class PointType, class LabelType>
template<PolygonConcept OtherPolygon>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherPolygon & other) const
constexpr

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::Convex< PointType, LabelType >::interiorContains ( const OtherPolyline & 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::Convex< PointType, LabelType >::interiorContains ( const OtherRay & ) const
constexpr

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

Template Parameters
OtherPointThe point type of the ray.
Parameters
otherThe ray to check.
Returns
Always returns false since a ray cannot be fully contained in A convex polygon.

◆ interiorContains() [13/19]

template<class PointType, class LabelType>
template<RectangleConcept OtherRectangle>
bool pgl::Convex< PointType, LabelType >::interiorContains ( const OtherRectangle & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the rectangle.
Parameters
otherThe rectangle to check.
Returns
True if the interior of the convex polygon contains the rectangle, false otherwise.

◆ interiorContains() [14/19]

template<class PointType_, class TLabel>
template<PolygonWithHolesConcept OtherRegion>
bool pgl::Convex< 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::Convex< 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::Convex< PointType, LabelType >::interiorContains ( const OtherSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the segment.
Parameters
otherThe segment to check.
Returns
True if the interior of the convex polygon contains the segment, false otherwise.

◆ interiorContains() [17/19]

template<class PointType_, class TLabel>
template<PolygonSetConcept OtherSet>
bool pgl::Convex< 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::Convex< PointType, LabelType >::interiorContains ( const OtherTriangle & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the triangle.
Parameters
otherThe triangle to check.
Returns
True if the interior of the convex polygon contains the triangle, false otherwise.

◆ interiorContains() [19/19]

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

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

◆ interiorsIntersect() [1/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

◆ interiorsIntersect() [2/14]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::interiorsIntersect ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(min(n,m) log(m+n)) for polygons with n and m vertices. A bounding-box test filters disjoint inputs in O(1).

◆ interiorsIntersect() [3/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(n) for n vertices on this convex polygon.

◆ interiorsIntersect() [4/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [5/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [6/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [7/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [8/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [9/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

Uses intersection to obtain the convex polygon-ray intersect exactly in O(log n); the interiors meet iff the intersect is a non-degenerate chord not lying on the convex polygon boundary.

◆ interiorsIntersect() [10/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [11/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

Uses intersection to obtain the convex polygon-segment intersect exactly in O(log n); the interiors meet iff the intersect is a non-degenerate chord not lying on the convex polygon boundary.

◆ interiorsIntersect() [12/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

◆ interiorsIntersect() [13/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

Complexity: O(log n) for n vertices.

◆ interiorsIntersect() [14/14]

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

Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).

◆ intersection() [1/14]

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

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

◆ intersection() [2/14]

template<class PointType, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

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

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the other convex polygon.
Parameters
otherThe other convex polygon to intersect with.
Returns
An optional variant containing either a point or segment or convex polygon representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [3/14]

template<class PointType, class LabelType>
template<class ResultNumber, HalfplaneConcept OtherHalfplane>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherHalfplane & other) const
constexpr

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

Clips the convex polygon to the closed half-plane. Complexity: O(log n + k log k) where n is the input size and k is the output size.

Template Parameters
ResultNumberThe number type for the result.
OtherHalfplaneThe half-plane type to intersect with.
Parameters
otherThe half-plane to intersect with.
Returns
An optional variant containing either a point or segment or convex polygon representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [4/14]

template<class PointType, class LabelType>
template<class ResultNumber, LineConcept OtherLine>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherLine & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the line.
Parameters
otherThe line to intersect with.
Returns
An optional variant containing either a point or segment representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [5/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedLineConcept OtherOrientedLine>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherOrientedLine & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the oriented line.
Parameters
otherThe oriented line to intersect with.
Returns
An optional variant containing either a point or segment representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [6/14]

template<class PointType, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherOrientedSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the oriented segment.
Parameters
otherThe oriented segment to intersect with.
Returns
An optional variant containing either a point or segment representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [7/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned point.
OtherPointPoint type.
Parameters
otherPoint to intersect with.
Returns
The point when contained, otherwise empty.

◆ intersection() [8/14]

template<class PointType, class LabelType>
template<class ResultNumber, RayConcept OtherRay>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherRay & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the ray.
Parameters
otherThe ray to intersect with.
Returns
An optional variant containing either a point or segment representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [9/14]

template<class PointType, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherRectangle & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the rectangle.
Parameters
otherThe rectangle to intersect with.
Returns
An optional variant containing either a point or segment or convex polygon representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [10/14]

template<class PointType_, class TLabel>
template<class ResultNumber = NumberType, HalfplaneIntersectionConcept OtherRegion>
auto pgl::Convex< PointType_, TLabel >::intersection ( const OtherRegion & other) const
inlinenodiscardconstexpr

Adds this convex polygon's constraints to a half-plane intersection without deriving vertices.

◆ intersection() [11/14]

template<class PointType, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherSegment & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the segment.
Parameters
otherThe segment to intersect with.
Returns
An optional variant containing either a point or segment representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [12/14]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!PointConcept<OtherShape> && !HalfplaneIntersectionConcept<OtherShape> && (detail::shapeRank<OtherShape>
> detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self) { o.template intersection
<ResultNumber>(self); })
auto pgl::Convex< 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() [13/14]

template<class PointType, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
std::optional< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > >, Convex< Point< ResultNumber, typename PointType::LabelType > > > > pgl::Convex< PointType, LabelType >::intersection ( const OtherTriangle & other) const
constexpr

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

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberThe number type for the result.
OtherPointThe point type of the triangle.
Parameters
otherThe triangle to intersect with.
Returns
An optional variant containing either a point or segment or convex polygon representing the intersection, or empty if no intersection.
Warning
Divides coordinates after casting to ResultNumber.

◆ intersection() [14/14]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< 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/14]

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

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

◆ intersects() [2/14]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::intersects ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Complexity: O(min(n,m) log(n+m)) for convex polygons with n and m vertices. Cheap bounding-box check filters out disjoint cases in O(1).

Template Parameters
OtherPointThe point type of the other convex polygon.
Parameters
otherThe convex polygon to check intersection with.
Returns
True if the convex polygons share any point.

◆ intersects() [3/14]

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

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

Complexity: O(n) for n vertices on this convex polygon.

◆ intersects() [4/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the half-plane.
Parameters
otherThe half-plane to check intersection with.
Returns
True if any polygon vertex lies in the closed half-plane.

◆ intersects() [5/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the line.
Parameters
otherThe line to check intersection with.
Returns
True if the convex polygon and line intersect, false otherwise.

◆ intersects() [6/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the oriented line.
Parameters
otherThe oriented line to check intersection with.
Returns
True if the convex polygon and oriented line intersect, false otherwise.

◆ intersects() [7/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the oriented segment.
Parameters
otherThe oriented segment to check intersection with.
Returns
True if the convex polygon and oriented segment intersect, false otherwise.

◆ intersects() [8/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type to check.
Parameters
otherThe point to check.
Returns
True if the point is contained in the convex polygon.

◆ intersects() [9/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the ray.
Parameters
otherThe ray to check intersection with.
Returns
True if the convex polygon and ray intersect, false otherwise.

◆ intersects() [10/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the rectangle.
Parameters
otherThe rectangle to check intersection with.
Returns
True if the convex polygon and rectangle intersect, false otherwise.

◆ intersects() [11/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the segment.
Parameters
otherThe segment to check intersection with.
Returns
True if the convex polygon and segment intersect, false otherwise.

◆ intersects() [12/14]

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

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

◆ intersects() [13/14]

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

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

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type of the triangle.
Parameters
otherThe triangle to check intersection with.
Returns
True if the convex polygon and triangle intersect, false otherwise.

◆ intersects() [14/14]

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

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

◆ isDegenerate()

template<class PointType, class LabelType>
bool pgl::Convex< PointType, LabelType >::isDegenerate ( ) const
constexpr

Checks if the convex polygon is degenerate (has zero area).

The empty convex polygon has no area either, so it is degenerate.

Returns
True if the convex polygon is degenerate, false otherwise.

◆ isPoint()

template<class PointType, class LabelType>
bool pgl::Convex< PointType, LabelType >::isPoint ( ) const
nodiscardconstexpr

Returns whether the convex polygon collapses to a single point.

The hull invariant keeps the vertices distinct, so this normally means a single stored vertex; coincident vertices of a trusted polygon are handled too.

Complexity: O(1).

Returns
true if the polygon covers exactly one point.

◆ isSegment()

template<class PointType, class LabelType>
bool pgl::Convex< PointType, LabelType >::isSegment ( ) const
nodiscardconstexpr

Returns whether the convex polygon collapses to a non-degenerate segment.

Holds when exactly two distinct vertices are stored.

Complexity: O(1).

Returns
true if the polygon is a segment of positive length.

◆ isUndefined()

template<class PointType, class LabelType>
bool pgl::Convex< PointType, LabelType >::isUndefined ( ) const
nodiscardconstexpr

Returns whether the convex polygon is degenerate without collapsing to a point or to a segment.

A convex polygon is never undefined: a degenerate one is always empty, a point, or a segment, so this always returns false. Use empty to detect the one that covers nothing. Provided for uniformity with the other shapes.

Complexity: O(1).

Returns
false.

◆ label()

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

Returns the convex-polygon label.

The label is mutable even through a const convex polygon: 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::Convex< PointType, LabelType >::latticePoints ( ) const
nodiscard

Returns the integer points the convex polygon contains.

The boundary included: a point on an edge is a point of the shape. The boundary answers for its own points, edge by edge as segments, and a sweep over the columns of the bounding box answers for the rest, so the cost is one pass over the edges plus one point per point reported.

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, in increasing order, 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.

◆ lowerHull()

template<class PointType_, class TLabel>
MonotoneChain< PointType > pgl::Convex< PointType_, TLabel >::lowerHull ( ) const
inlineconstexpr

Returns the lower hull: the boundary chain running from the lexicographically smallest vertex to the lexicographically largest one, counterclockwise (below the polygon).

The two chains share their extreme vertices and together cover the whole boundary. A vertical edge at the rightmost x belongs to the lower hull, a vertical edge at the leftmost x to the upper hull, because the extremes are the lexicographic ones. For a degenerate convex polygon (at most two vertices) both chains are the polygon itself.

Complexity: O(n) for n vertices.

Returns
The lower boundary chain, with no chain label.

◆ maxIndex()

template<class PointType, class LabelType>
size_t pgl::Convex< PointType, LabelType >::maxIndex ( ) const
constexpr

Returns the index of the maximum vertex (rightmost and highest in case of ties).

Complexity: O(log n) for n vertices.

Returns
The maximum vertex index.

◆ minimumWidth()

template<class PointType, class LabelType>
template<class ApproximateNumber>
ApproximateNumber pgl::Convex< PointType, LabelType >::minimumWidth ( ) const
nodiscard

Returns the minimum width of the convex polygon.

The distance between the two supporting lines of smallestEnclosingSlab. Generally irrational, hence the floating-point return type; use squaredMinimumWidth to compare widths exactly. Divides the supporting distance by the edge length rather than taking the root of the squared width, so only one square root enters the result.

A polygon with fewer than three vertices returns zero.

Complexity: O(n) for n vertices.

Template Parameters
ApproximateNumberFloating-point return type.
Returns
The minimum width.

◆ minkowskiErosion() [1/2]

template<class PointType_, class TLabel>
template<class OtherShape>
requires (!MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape> && BoundedPolygonalConcept<OtherShape>)
auto pgl::Convex< PointType_, TLabel >::minkowskiErosion ( const OtherShape & other) const
nodiscardconstexpr

Returns the Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B).

The pairs MinkowskiSummableConcept turns away, which are exactly the ones whose sum needs a region: a sum sweeps the operand's concavity into its answer, so it is the operand that decides the result type, and minkowskiSum hands the pair over to it.

An erosion reads the operand only through its support function, and a support function sees no further than the convex hull – A ⊖ B is A ⊖ hull(B) for a convex A. So this shape keeps the pair and answers it with the same convex region it erodes to by any other operand, at a cost linear in the two sizes: a Polygon, a PolygonWithHoles, a PolygonSet, a Polyline and a MonotoneChain are all as cheap here as their vertex count.

Template Parameters
OtherShapeType of the shape to erode by.
Parameters
otherShape to erode by.
Returns
The erosion, as a HalfplaneIntersection – the whole plane when other covers no point.

◆ minkowskiErosion() [2/2]

template<class PointType_, class TLabel>
requires MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape>
template<class OtherShape>
requires MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape>
auto pgl::Convex< PointType_, TLabel >::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 convex polygon erodes to the region its own constraints leave once each is moved in.

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/2]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires (!MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank
<Convex>) && requires(const OtherShape& o, const Convex& self) { o.template minkowskiSum<ResultNumber>(self); })
auto pgl::Convex< PointType_, TLabel >::minkowskiSum ( const OtherShape & other) const
inlinenodiscard

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

The pairs MinkowskiSummableConcept rejects are exactly the ones whose sum needs a region-valued result rather than one bounded convex shape; they are implemented on Polygon and PolygonWithHoles. Forwards to the other shape's implementation so that each unordered pair needs the sum defined only once, on the higher-ranked shape.

◆ minkowskiSum() [2/2]

template<class PointType, class LabelType>
requires MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape>
template<class OtherShape>
requires MinkowskiSummableConcept<Convex<PointType_, TLabel>, OtherShape>
auto pgl::Convex< 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.

◆ operator Polygon< PointType >()

template<class PointType_, class TLabel>
pgl::Convex< PointType_, TLabel >::operator Polygon< PointType > ( ) const
inlineexplicitnodiscardconstexpr

Converts the convex polygon to a simple polygon.

The vertices already follow the canonical polygon order (counterclockwise, lexicographically smallest first).

Returns
Polygon with the same vertices.

◆ operator*=() [1/2]

template<class PointType_, class TLabel>
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
Convex< PointType, LabelType > & pgl::Convex< PointType_, TLabel >::operator*= ( const Scalar & scalar)
constexpr

◆ operator*=() [2/2]

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

Scales the convex polygon by the given scalar.

Complexity: O(n) for n vertices since we need to apply the scaling to each vertex.

Template Parameters
ScalarThe scalar type.
Parameters
scalarThe scaling factor.
Returns
A reference to the modified polygon.

◆ operator+=() [1/2]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
Convex< PointType, LabelType > & pgl::Convex< PointType_, TLabel >::operator+= ( const OtherPoint & translation)
constexpr

◆ operator+=() [2/2]

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

Translates the convex polygon by the given point in place.

◆ operator-=() [1/2]

template<class PointType_, class TLabel>
template<PointConcept OtherPoint>
Convex< PointType, LabelType > & pgl::Convex< PointType_, TLabel >::operator-= ( const OtherPoint & translation)
constexpr

◆ operator-=() [2/2]

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

Translates the convex polygon by the negation of the given point.

Complexity: O(1).

Template Parameters
OtherPointThe point type of the translation vector.
Parameters
translationThe translation vector to negate.
Returns
A reference to the modified polygon.

◆ operator/=() [1/2]

template<class PointType_, class TLabel>
template<class Scalar>
requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
Convex< PointType, LabelType > & pgl::Convex< PointType_, TLabel >::operator/= ( const Scalar & scalar)
constexpr

◆ operator/=() [2/2]

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

Divides the convex polygon by the given scalar.

Complexity: O(n) for n vertices since we need to apply the division to each vertex.

Template Parameters
ScalarThe scalar type.
Parameters
scalarThe divisor.
Returns
A reference to the modified polygon.

◆ operator<=>()

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

Compares two convex polygons.

Parameters
otherThe other convex polygon to compare with.
Returns
The three-way comparison result.

◆ operator==()

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

Checks equality of two convex polygons.

Parameters
otherThe other convex polygon to compare with.
Returns
True if both polygons have the same vertices in the same order.

◆ operator[]()

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

Accesses a vertex by index.

Parameters
indexThe index of the vertex.
Returns
A constant reference to the vertex at the given index.

◆ orientedEdges()

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

Returns the oriented edges of the convex polygon.

Returns
A vector of oriented segments representing the edges.

◆ orientedEdgesBegin()

template<class PointType_, class TLabel>
OrientedEdgeIterator pgl::Convex< 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::Convex< 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::Convex< PointType_, TLabel >::orientedEdgesView ( ) const
inlineconstexpr

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

◆ pointInside()

template<class PointType, class LabelType>
template<class ResultNumber>
Point< ResultNumber > pgl::Convex< PointType, LabelType >::pointInside ( ) const
constexpr

Returns a point inside the convex polygon.

Complexity: O(1).

Template Parameters
ResultNumberThe number type for the result.
Returns
A point guaranteed to be inside the convex polygon.
Warning
Divides coordinates by 4. Inexact for integer coordinates not divisible by 4.

◆ pointInsideInteriorContainedIn()

template<class PointType, class LabelType>
template<class OtherShape>
bool pgl::Convex< PointType, LabelType >::pointInsideInteriorContainedIn ( const OtherShape & shape) const
nodiscardconstexpr

Tests whether some point in this shape's relative interior lies in the strict interior of shape.

Uses pointInside as the witness. When integer truncation rounds that witness onto or outside the boundary, this shape and shape are scaled so the witness is exact, leaving the containment relation unchanged.

◆ regularizedIntersection() [1/2]

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

Forwards a regularized intersection to the shape that owns it.

◆ regularizedIntersection() [2/2]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::regularizedIntersection ( const Shape< OtherPoint > & other) const
inlinenodiscard

Re-dispatches a regularized intersection through a runtime shape.

◆ regularizedUnion() [1/8]

template<class PointType_, class TLabel>
template<class ResultNumber, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::regularizedUnion ( const OtherConvex< PointType_, TLabel > & other) const

◆ regularizedUnion() [2/8]

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

Returns the regularized union of the two shapes (A ∪ B).

The union of two bounded convex shapes is convex only by coincidence — two that overlap in a corner make an L, and two that are apart make two pieces — so it answers with a set of regions like every other union. A convex polygon is the highest-ranked of the three bounded convex regions, so it owns its pairs with all three; the pairs with an operand above it are defined there and reached through the forwarding overload below. See Polygon::regularizedUnion for the contract.

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

◆ regularizedUnion() [3/8]

template<class PointType_, class TLabel>
template<class ResultNumber, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::regularizedUnion ( const OtherRectangle & other) const

◆ regularizedUnion() [4/8]

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

Returns the regularized union of the two shapes (A ∪ B).

◆ regularizedUnion() [5/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template regularizedUnion<ResultNumber>(self); })
auto pgl::Convex< PointType_, TLabel >::regularizedUnion ( const OtherShape & other) const
inlinenodiscard

Returns the regularized union of the two shapes (A ∪ B).

Forwards to the other shape's implementation so that each unordered pair needs regularizedUnion defined only once, on the higher-ranked shape. See Polygon::regularizedUnion for the contract.

◆ regularizedUnion() [6/8]

template<class PointType_, class TLabel>
template<class ResultNumber, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::regularizedUnion ( const OtherTriangle & other) const

◆ regularizedUnion() [7/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Convex< PointType_, TLabel >::regularizedUnion ( const OtherTriangle & other) const
nodiscard

Returns the regularized union of the two shapes (A ∪ B).

◆ regularizedUnion() [8/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::regularizedUnion ( const Shape< OtherPoint > & other) const
inlinenodiscard

Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own regularizedUnion.

A union is symmetric, so this just calls other's own regularizedUnion, which visits its wrapped alternative and throws if the pair is unsupported — here, whenever other turns out to hold anything but a bounded polygonal region. See Polygon::regularizedUnion for the contract.

The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.

◆ rotate90()

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

Rotates the convex polygon by 90k degrees around the origin in place.

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

◆ rotated90()

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

Returns the convex polygon rotated by 90k degrees around the origin.

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

◆ samePointSet()

template<class PointType, class LabelType>
template<AnyShapeConcept OtherShape>
bool pgl::Convex< 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>
Convex< PointType, LabelType > pgl::Convex< PointType_, TLabel >::scaledDownX ( const OtherNumber scalar) const
constexpr

◆ scaledDownX() [2/2]

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

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

◆ scaledDownY() [1/2]

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

◆ scaledDownY() [2/2]

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

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

◆ scaleDownX()

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

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

◆ scaleDownY()

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

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

◆ scaledUpX() [1/2]

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

◆ scaledUpX() [2/2]

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

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

◆ scaledUpY() [1/2]

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

◆ scaledUpY() [2/2]

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

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

◆ scaleUpX()

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

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

◆ scaleUpY()

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

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

◆ separates() [1/19]

template<class PointType_, class TLabel>
template<class EmptyPoint>
bool pgl::Convex< 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::Convex< PointType, LabelType >::separates ( const OtherChain & other) const
nodiscardconstexpr

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

◆ separates() [3/19]

template<class PointType, class LabelType>
template<ConvexConcept OtherConvex>
bool pgl::Convex< PointType, LabelType >::separates ( const OtherConvex< PointType_, TLabel > & other) const
constexpr

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

Complexity: O(min(n,m) log(m+n)) for convex polygons with n vertices and m vertices.

◆ separates() [4/19]

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

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

Complexity: O(n) for n vertices on this convex polygon.

◆ separates() [5/19]

template<class PointType, class LabelType>
template<HalfplaneConcept OtherHalfplane>
bool pgl::Convex< PointType, LabelType >::separates ( const OtherHalfplane & ) const
constexpr

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

Complexity: O(1).

◆ separates() [6/19]

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

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

Complexity: O(log n) for n vertices.

◆ separates() [7/19]

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

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

Complexity: O(log n) for n vertices.

◆ separates() [8/19]

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

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

Complexity: O(log n) for n vertices.

◆ separates() [9/19]

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Convex< PointType, LabelType >::separates ( const OtherPoint & ) const
constexpr

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

Complexity: O(1).

◆ separates() [10/19]

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

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

Unlike the Convex overload, a reflex polygon can dip into the convex body through several separate pockets while staying connected, so counting boundary arcs is not enough. The polygon is cut iff some connected component of the intersection touches the polygon boundary in two or more pieces, detected by walking the contacts around the convex boundary; this includes a convex body inside the polygon that pinches the boundary at two touch points.

Complexity: O(n log m + c m + c log c) for n polygon vertices, m convex polygon vertices, and c boundary contacts.

◆ separates() [11/19]

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

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

◆ separates() [12/19]

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

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

Complexity: O(log n) for n vertices.

The ray is split iff its source lies outside the closed polygon (so the leading piece survives) and the ray actually intersects the convex polygon.

◆ separates() [13/19]

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

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

Complexity: O(log n) for n vertices (four edge checks).

◆ separates() [14/19]

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

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

Complexity: O(log n) for n vertices.

A segment collinear with one of the convex polygon's boundary edges is not separated by the convex polygon — the convex polygon only touches the segment along the boundary, not through its interior, so the two outside extensions are not produced by removing the convex polygon's body. We therefore require the segment to cross the convex polygon interior, not just intersect it.

◆ separates() [17/19]

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

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

Complexity: O(log n) for n vertices (three edge checks).

◆ separates() [19/19]

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

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

◆ size()

template<class PointType_, class TLabel>
size_t pgl::Convex< PointType_, TLabel >::size ( ) const
inline

Returns the number of vertices in the convex polygon.

Returns
The number of vertices.

◆ smallestEnclosingDisk() [1/3]

template<class PointType, class LabelType>
Disk< Point< typename Convex< PointType, LabelType >::NumberType > > pgl::Convex< PointType, LabelType >::smallestEnclosingDisk ( ) const
nodiscard

Returns the smallest closed disk containing the convex polygon.

This overload supplies the generator for the randomized incremental order, from a fixed seed, so the same polygon always yields the same disk. See the generator-taking overload for the contract.

Complexity: expected O(n) for n vertices.

Precondition
The convex polygon is not empty.
Warning
A disk supported by two vertices divides coordinates by two, so all coordinates should be even when an integral type is used; otherwise integer division can truncate the result.
Returns
The unique smallest enclosing disk.

◆ smallestEnclosingDisk() [2/3]

template<class PointType_, class TLabel>
template<class UniformRandomBitGenerator>
Disk< Point< typename Convex< PointType, LabelType >::NumberType > > pgl::Convex< PointType_, TLabel >::smallestEnclosingDisk ( UniformRandomBitGenerator && generator) const

◆ smallestEnclosingDisk() [3/3]

template<class PointType_, class TLabel>
template<class UniformRandomBitGenerator>
Disk< Point< NumberType > > pgl::Convex< PointType_, TLabel >::smallestEnclosingDisk ( UniformRandomBitGenerator && generator) const
nodiscard

Returns the smallest closed disk containing the convex polygon.

Delegates to pgl::smallestEnclosingDisk over the hull vertices, which is enough: a disk containing the vertices contains their hull. The returned disk keeps the coordinate number type and drops labels.

Complexity: expected O(n) for n vertices.

Template Parameters
UniformRandomBitGeneratorGenerator accepted by std::shuffle.
Parameters
generatorGenerator used to randomize the incremental order.
Precondition
The convex polygon is not empty.
Warning
A disk supported by two vertices divides coordinates by two, so all coordinates should be even when an integral type is used; otherwise integer division can truncate the result.
Returns
The unique smallest enclosing disk.

◆ smallestEnclosingRectangle()

template<class PointType, class LabelType>
HalfplaneIntersection< PointType > pgl::Convex< PointType, LabelType >::smallestEnclosingRectangle ( ) const
nodiscardconstexpr

Returns the smallest-area rectangle containing the convex polygon.

A minimum-area enclosing rectangle always has one side flush with an edge of the polygon, so a single rotating-calipers sweep over the edges finds it: for each edge, three support vertices (the two extremes along the edge direction and the farthest one from the edge line) give the rectangle flush with that edge, and the sweep advances each support forward only.

The rectangle is generally not axis-parallel, and its corners are generally not representable in NumberType: they divide by the squared length of the edge the rectangle rests on. Its four supporting lines are, though — each runs through a vertex, along the flush edge or along that edge turned 90 degrees. So the result is a HalfplaneIntersection, which is exact in the polygon's own coordinate type, and the caller asks for the corners at whatever precision it wants, with k.vertices<ResultNumber>() or k.asConvex<ResultNumber>().

A polygon with fewer than three vertices has no area to enclose: the result is the polygon's own region, exactly as asHalfplaneIntersection returns it (empty, a point, or a segment).

Complexity: O(n) for n vertices. Comparing two candidate areas is degree six in the coordinates, past what a promoted coordinate type holds, so that comparison runs in a type that grows to hold it: pgl::BigInt for integral coordinates, pgl::ERational for rational ones, and the promoted floating-point type — no exact type — for floating-point ones.

Warning
Each supporting line is defined by a vertex and by that vertex translated along an edge vector, so the defining coordinates reach about twice the extent of the polygon.
Returns
The smallest-area enclosing rectangle, as four half-planes.

◆ smallestEnclosingSlab()

template<class PointType, class LabelType>
HalfplaneIntersection< PointType > pgl::Convex< PointType, LabelType >::smallestEnclosingSlab ( ) const
nodiscardconstexpr

Returns the narrowest slab containing the convex polygon.

The width of a convex polygon is the smallest distance between two parallel supporting lines, and the slab they bound is what this returns. The minimum is always attained with one of the two lines flush with an edge, so a single rotating-calipers sweep over the edges finds it: for each edge, the farthest vertex from that edge's line gives the slab flush with it, and that support advances forward only.

Both supporting lines are exact in NumberType – one runs along an edge, the other through a vertex along that same edge vector – while the distance between them is not, since it divides by the edge length and takes a square root. So the region comes back as a HalfplaneIntersection, exact in the polygon's own coordinate type, and the width itself is asked for separately with squaredMinimumWidth or minimumWidth. The slab is unbounded, so it has no bbox(); k.vertices<ResultNumber>() is empty for it.

A polygon with fewer than three vertices has no width to minimize: the result is the polygon's own region, exactly as asHalfplaneIntersection returns it (empty, a point, or a segment), which is the degenerate slab of width zero.

Complexity: O(n) for n vertices. Comparing two candidate widths is degree six in the coordinates, past what a promoted coordinate type holds, so that comparison runs in a type that grows to hold it: pgl::BigInt for integral coordinates, pgl::ERational for rational ones, and the promoted floating-point type – no exact type – for floating-point ones.

Warning
The second supporting line is defined by a vertex and by that vertex translated along an edge vector, so the defining coordinates reach about twice the extent of the polygon.
See also
smallestEnclosingRectangle() for the bounded counterpart.
Returns
The narrowest enclosing slab, as two half-planes.

◆ squaredDistance() [1/12]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::squaredDistance ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the squared Euclidean distance to the given shape.

Zero when the two convex polygons intersect; otherwise the smallest squared distance between them.

For two disjoint convex polygons the closest point of one lies on its boundary, hence on one of its edges. The minimum over all edges of one polygon of the edge-to-polygon distance therefore equals the polygon-to- polygon distance. The edges of the polygon with fewer vertices are queried — each query is the O(log m) squaredDistance(const OtherSegment&) search against the other polygon.

An overlap test guards the case where the fewer-vertex polygon strictly contains the other: there no edge of the queried polygon meets the other, yet the true distance is zero.

Complexity: O(min(n,m) log(n+m)) for polygons with n and m vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherConvexThe other convex polygon type.
Parameters
otherThe convex polygon to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [2/12]

template<class PointType_, class LabelType>
template<class ResultNumber, DiskConcept OtherDisk>
detail::floating_result_t< ResultNumber > pgl::Convex< PointType_, LabelType >::squaredDistance ( const OtherDisk & other) const
nodiscard

Returns the squared Euclidean distance to the given shape.

Zero when the disk and the polygon intersect; otherwise the square of distance(center, polygon) - radius, the gap between the polygon and the nearest point of the circle.

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.

Complexity: O(log n) for n vertices.

Template Parameters
OtherDiskThe disk type.
Parameters
otherThe disk to measure to.

◆ squaredDistance() [3/12]

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

Returns the squared Euclidean distance to the given shape.

Zero when the polygon intersects the half-plane; otherwise the polygon lies entirely on the far side of the boundary line, so its closest point of the half-plane is on that boundary and the distance equals the distance to Halfplane::asLine.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherHalfplaneThe half-plane type.
Parameters
otherThe half-plane to measure to.
Warning
With an integer ResultNumber the perpendicular distance divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [4/12]

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

Returns the squared Euclidean distance to the given shape.

Zero when the line intersects the convex polygon; otherwise the smallest squared distance between the two shapes.

A line disjoint from the polygon leaves the whole polygon on one side, so the closest point of the polygon is the vertex extremal along the line normal toward the line. The signed-distance functional is linear, hence cyclic-unimodal over the CCW vertices; its two extrema — the only candidates — are located with the same O(log n) cyclic search used by the segment overload, and the nearer of the two gives the exact minimum.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherLineThe line type.
Parameters
otherThe line to measure to.
Warning
With an integer ResultNumber the perpendicular distance divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [5/12]

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

Returns the squared Euclidean distance to the given shape.

Orientation does not affect distance, so this forwards to the unoriented squaredDistance(const OtherLine&) overload via OrientedLine::asLine.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherOrientedLineThe oriented line type.
Parameters
otherThe oriented line to measure to.
Warning
With an integer ResultNumber the perpendicular distance divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [6/12]

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

Returns the squared Euclidean distance to the given shape.

Orientation does not affect distance, so this forwards to the unoriented squaredDistance(const OtherSegment&) overload.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherOrientedSegmentThe oriented segment type.
Parameters
otherThe oriented segment to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [7/12]

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

Returns the squared Euclidean distance to the given shape.

Zero when the convex polygon contains the point (boundary included); otherwise the smallest squared distance from the point to an edge.

For an exterior point the closest boundary point lies on the contiguous chain of edges that face the point. That chain is located in logarithmic time: an interior reference point and two support-function searches bracket the edge the ray to the query exits through (which faces the query) and the opposite edge; a binary search then grows the facing chain, over which the per-edge distance is unimodal, and a final binary search picks the closest edge. The per-vertex distances themselves are not unimodal, so a direct search over vertices does not work.

Complexity: O(log n) for n vertices.

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/12]

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

Returns the squared Euclidean distance to the given shape.

Zero when the ray intersects the convex polygon; otherwise the smallest squared distance between the two shapes.

For disjoint inputs the closest pair is realized either between the ray's source and the polygon, or between a polygon vertex and the interior of the ray. The first witness is the O(log n) squaredDistance(const OtherPoint&) query on the source. The remaining witnesses lie on the polygon vertices extremal along the ray normal: that functional is linear, hence cyclic-unimodal over the CCW vertices, so its two extrema are found with the same O(log n) cyclic search used by the segment overload. Measuring those vertices with Ray::squaredDistance clamps to the ray, absorbing the cases where the extremal vertex projects behind the source (the source query then supplies the true minimum).

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherRayThe ray type.
Parameters
otherThe ray to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [9/12]

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

Returns the squared Euclidean distance to the given shape.

Forwards to the squaredDistance(const OtherConvex&) overload via the rectangle's Rectangle::asConvex representation.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherRectangleThe rectangle type.
Parameters
otherThe rectangle to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [10/12]

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

Returns the squared Euclidean distance to the given shape.

Zero when the convex polygon and the segment intersect; otherwise the smallest squared distance between the two shapes.

For disjoint inputs the closest pair is realized either between a segment endpoint and the polygon, or between a polygon vertex and the interior of the segment. The first two witnesses are the two squaredDistance point-to-polygon queries on the endpoints. The third witness, when it exists, lies on the polygon vertex nearest the segment's supporting line: a vertex extremal along the segment normal. That normal functional is linear, hence cyclic-unimodal over the CCW vertices, so its two extrema — the candidate witnesses — are found with the same O(log n) cyclic search used elsewhere. The endpoint queries absorb every case in which the extremal vertex projects outside the segment (including a polygon edge parallel to the segment), so the four candidates together give the exact minimum.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherSegmentThe segment type.
Parameters
otherThe segment to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredDistance() [11/12]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template squaredDistance<ResultNumber>(self); })
auto pgl::Convex< 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 (the only shape ranked above Convex is Polygon).

◆ squaredDistance() [12/12]

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

Returns the squared Euclidean distance to the given shape.

Forwards to the squaredDistance(const OtherConvex&) overload via the triangle's Triangle::asConvex representation.

Complexity: O(log n) for n vertices.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: division_result_t).
OtherTriangleThe triangle type.
Parameters
otherThe triangle to measure to.
Warning
With an integer ResultNumber a perpendicular witness divides a squared length, so the result truncates and is inexact. Request a floating-point or pgl::Rational result type for an accurate value.

◆ squaredHausdorffDistance() [1/7]

template<class PointType_, class LabelType>
template<class ResultNumber, ConvexConcept OtherConvex>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherConvex< PointType_, TLabel > & other) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredHausdorffDistance() [2/7]

template<class PointType_, class LabelType>
template<class ResultNumber, OrientedSegmentConcept OtherOrientedSegment>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherOrientedSegment & other) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredHausdorffDistance() [3/7]

template<class PointType_, class LabelType>
template<class ResultNumber, PointConcept OtherPoint>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherPoint & point) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredHausdorffDistance() [4/7]

template<class PointType_, class LabelType>
template<class ResultNumber, RectangleConcept OtherRectangle>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherRectangle & other) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredHausdorffDistance() [5/7]

template<class PointType_, class LabelType>
template<class ResultNumber, SegmentConcept OtherSegment>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherSegment & other) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredHausdorffDistance() [6/7]

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

Returns the squared Hausdorff distance to the given shape.

Forwards to the other shape's implementation so that each unordered pair needs squaredHausdorffDistance defined only once, on the higher-ranked shape (the only shape ranked above Convex is Polygon).

◆ squaredHausdorffDistance() [7/7]

template<class PointType_, class LabelType>
template<class ResultNumber, TriangleConcept OtherTriangle>
auto pgl::Convex< PointType_, LabelType >::squaredHausdorffDistance ( const OtherTriangle & other) const
nodiscardconstexpr

Returns the squared Hausdorff distance to the given shape.

The directed Hausdorff distance in either direction is attained at a vertex of the source shape, since distance to a convex shape is convex and its supremum over any polygon is attained at a vertex.

Template Parameters
ResultNumberCoordinate type of the returned distance (default: NumberType).

◆ squaredMinimumWidth()

template<class PointType, class LabelType>
template<class ResultNumber>
ResultNumber pgl::Convex< PointType, LabelType >::squaredMinimumWidth ( ) const
nodiscardconstexpr

Returns the squared minimum width of the convex polygon.

The width divides by an edge length and is therefore irrational, but its square is the fraction (2 * area)^2 / |edge|^2 and stays exact: this is the form to compare against a threshold or between polygons, the way squaredLength and squaredDistance are used elsewhere. Fitting through a gap of width w is squaredMinimumWidth() <= w * w, decided exactly for integral coordinates.

A polygon with fewer than three vertices has no width to minimize and returns zero, which is the width of its degenerate slab.

Complexity: O(n) for n vertices.

Template Parameters
ResultNumberType of the returned value (default: division_result_t).
Warning
An explicitly integral ResultNumber truncates the fraction, and squaring the numerator in it may overflow; the default type holds the value exactly.
See also
smallestEnclosingSlab() for the two supporting lines realizing it.
Returns
The squared minimum width.

◆ symmetricDifference() [1/8]

template<class PointType_, class TLabel>
template<class ResultNumber, ConvexConcept OtherConvex>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::symmetricDifference ( const OtherConvex< PointType_, TLabel > & other) const

◆ symmetricDifference() [2/8]

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

Returns the regularized symmetric difference of the two shapes (A △ B).

A convex polygon is the highest-ranked of the three bounded convex regions, so it owns its pairs with all three; the pairs with an operand above it are defined there and reached through the forwarding overload below. See Polygon::symmetricDifference for the contract.

Template Parameters
ResultNumberThe number type for the result.
Parameters
otherThe other shape.
Returns
The pieces of the symmetric difference, in canonical order.

◆ symmetricDifference() [3/8]

template<class PointType_, class TLabel>
template<class ResultNumber, RectangleConcept OtherRectangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::symmetricDifference ( const OtherRectangle & other) const

◆ symmetricDifference() [4/8]

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

Returns the regularized symmetric difference of the two shapes (A △ B).

◆ symmetricDifference() [5/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, typename OtherShape>
requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Convex>) && requires(const OtherShape& o, const Convex& self)
{ o.template symmetricDifference<ResultNumber>(self); })
auto pgl::Convex< PointType_, TLabel >::symmetricDifference ( const OtherShape & other) const
inlinenodiscard

Returns the regularized symmetric difference of the two shapes (A △ B).

Forwards to the other shape's implementation so that each unordered pair needs symmetricDifference defined only once, on the higher-ranked shape. See Polygon::symmetricDifference for the contract.

◆ symmetricDifference() [6/8]

template<class PointType_, class TLabel>
template<class ResultNumber, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > pgl::Convex< PointType_, TLabel >::symmetricDifference ( const OtherTriangle & other) const

◆ symmetricDifference() [7/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > pgl::Convex< PointType_, TLabel >::symmetricDifference ( const OtherTriangle & other) const
nodiscard

Returns the regularized symmetric difference of the two shapes (A △ B).

◆ symmetricDifference() [8/8]

template<class PointType_, class TLabel>
template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
auto pgl::Convex< PointType_, TLabel >::symmetricDifference ( const Shape< OtherPoint > & other) const
inlinenodiscard

Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wrapper's own symmetricDifference.

A symmetric difference is symmetric, so this just calls other's own, which visits its wrapped alternative and throws if the pair is unsupported. See Polygon::symmetricDifference for the contract.

The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.

◆ twiceArea()

template<class PointType, class LabelType>
auto pgl::Convex< PointType, LabelType >::twiceArea ( ) const
constexpr

Computes twice the area of the convex polygon.

Returns
Twice the area of the convex polygon.

◆ upperHull()

template<class PointType_, class TLabel>
MonotoneChain< PointType > pgl::Convex< PointType_, TLabel >::upperHull ( ) const
inlineconstexpr

Returns the upper hull: the boundary chain running from the lexicographically smallest vertex to the lexicographically largest one, clockwise (above the polygon).

See lowerHull for how the two chains split the boundary.

Complexity: O(n) for n vertices.

Returns
The upper boundary chain, with no chain label.

◆ vertices()

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

Returns the vertices of the convex polygon.

Returns
A vector of vertices.

◆ verticesCentroid()

template<class PointType, class LabelType>
template<class ResultNumber>
Point< ResultNumber > pgl::Convex< PointType, LabelType >::verticesCentroid ( ) const
constexpr

Computes the centroid of the vertex set.

Template Parameters
ResultNumberThe number type for the result.
Returns
The centroid of the vertex set.
Warning
Uses division by the number of vertices, so the result may be inexact even for floating-point types.

◆ verticesContain()

template<class PointType, class LabelType>
template<PointConcept OtherPoint>
bool pgl::Convex< PointType, LabelType >::verticesContain ( const OtherPoint & point) const
constexpr

Checks if the vertices list contains the given point.

Complexity: O(log n) for n vertices.

Template Parameters
OtherPointThe point type to check.
Parameters
pointThe point to check.
Returns
True if the point is a vertex, false otherwise.

◆ verticesView()

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

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

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