![]() |
Pangolin
Header-only C++20 plane computational geometry library
|
Unoriented closed segment between two endpoints plus optional segment label. More...
#include <segment.hpp>
Public Types | |
| using | PointType = TPoint |
| using | NumberType = PointType::NumberType |
| using | LabelType = TLabel |
Public Member Functions | |
| constexpr | Segment ()=default |
| Creates the degenerate segment (0,0)--(0,0). | |
| constexpr | Segment (PointType first, PointType second) |
| Creates a segment from two endpoints. | |
| constexpr | Segment (NumberType x1, NumberType y1, NumberType x2, NumberType y2) |
| Creates a segment from four coordinates. | |
| template<class A> requires (detail::has_label_v<LabelType> && std::constructible_from<LabelType, A&&>) | |
| constexpr | Segment (PointType first, PointType second, A &&label) |
| Creates a segment from two endpoints and stores a label. | |
| template<class A> requires (detail::has_label_v<LabelType> && std::constructible_from<LabelType, A&&>) | |
| constexpr | Segment (NumberType x1, NumberType y1, NumberType x2, NumberType y2, A &&label) |
| Same as the four-coordinate constructor, and stores a label. | |
| template<PointConcept OtherPointType, class OtherLabelType> requires (std::constructible_from<PointType, const OtherPointType&>) | |
| constexpr | Segment (const Segment< OtherPointType, OtherLabelType > &other) |
| Converts a segment with a different point and/or label type. | |
| template<PointConcept OtherPointType, class OtherLabelType> requires (std::constructible_from<PointType, const OtherPointType&>) | |
| constexpr Segment & | operator= (const Segment< OtherPointType, OtherLabelType > &other) |
| Assigns from a segment with compatible point and label types. | |
| constexpr const PointType & | operator[] (std::size_t index) const |
| Returns endpoint 0 or 1. | |
| constexpr const PointType & | get (std::ptrdiff_t index) const |
| Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end. | |
| constexpr std::ptrdiff_t | index (const PointType &point) const |
| Returns the smallest index i with (*this)[i] == point, or -1 if no endpoint equals point. | |
| constexpr const PointType & | min () const |
| Returns the smallest stored endpoint. | |
| constexpr const PointType & | max () const |
| Returns the largest stored endpoint. | |
| constexpr auto | begin () const |
| Returns an iterator to the first endpoint. | |
| constexpr auto | cbegin () const |
| Returns an iterator to the first endpoint. | |
| constexpr auto | end () const |
| Returns an iterator past the last endpoint. | |
| constexpr auto | cend () const |
| Returns an iterator past the last endpoint. | |
| constexpr bool | operator== (const Segment &other) const |
| Compares two segments by their endpoints; the label is ignored. | |
| template<AnyShapeConcept OtherShape> | |
| constexpr bool | samePointSet (const OtherShape &other) const |
| Tests whether another shape defines exactly the same point set. | |
| constexpr auto | operator<=> (const Segment &other) const |
| Provides lexicographic ordering on (x1,y1),(x2,y2). | |
| template<class A = LabelType> requires (detail::has_label_v<A>) | |
| constexpr A & | label () const |
| Returns the segment label. | |
| constexpr | operator Line< PointType > () const |
| Converts to the supporting unoriented line. | |
| constexpr Line< PointType > | asLine () const |
| Returns the supporting line. | |
| constexpr HalfplaneIntersection< PointType > | asHalfplaneIntersection () const |
| Returns the segment as a (degenerate) half-plane intersection. | |
| constexpr Segment | rotated90 (int k=1) const |
| Returns the segment rotated by 90k degrees around the origin. | |
| constexpr void | rotate90 (int k=1) |
| Rotates the segment by 90k degrees around the origin in place. | |
| template<class OtherNumber> | |
| constexpr Segment | scaledUpX (const OtherNumber scalar) const |
| Returns the segment with its x-coordinates multiplied by a factor. | |
| template<class OtherNumber> | |
| constexpr void | scaleUpX (const OtherNumber scalar) |
| Multiplies the segment's x-coordinates by a factor in place. | |
| template<class OtherNumber> | |
| constexpr Segment | scaledUpY (const OtherNumber scalar) const |
| Returns the segment with its y-coordinates multiplied by a factor. | |
| template<class OtherNumber> | |
| constexpr void | scaleUpY (const OtherNumber scalar) |
| Multiplies the segment's y-coordinates by a factor in place. | |
| template<class OtherNumber> | |
| constexpr Segment | scaledDownX (const OtherNumber scalar) const |
| Returns the segment with its x-coordinates divided by a divisor. | |
| template<class OtherNumber> | |
| constexpr void | scaleDownX (const OtherNumber scalar) |
| Divides the segment's x-coordinates by a divisor in place. | |
| template<class OtherNumber> | |
| constexpr Segment | scaledDownY (const OtherNumber scalar) const |
| Returns the segment with its y-coordinates divided by a divisor. | |
| template<class OtherNumber> | |
| constexpr void | scaleDownY (const OtherNumber scalar) |
| Divides the segment's y-coordinates by a divisor in place. | |
| constexpr bool | isDegenerate () const |
| Returns whether both endpoints coincide. | |
| constexpr bool | isPoint () const |
| Returns whether the segment collapses to a single point. | |
| constexpr std::optional< PointType > | getIfPoint () const |
| Returns the point the segment collapses to, if it does. | |
| constexpr bool | isUndefined () const |
| Returns whether the segment is degenerate without collapsing to a point or to a segment. | |
| constexpr bool | isVertical () const |
| Returns whether the segment is vertical. | |
| constexpr bool | isHorizontal () const |
| Returns whether the segment is horizontal. | |
| template<class ResultNumber = NumberType> | |
| constexpr ResultNumber | area () const |
| Returns the area of the segment. | |
| constexpr NumberType | twiceArea () const |
| Returns twice the area of the segment. | |
| constexpr auto | squaredLength () const |
| Returns the squared Euclidean length. | |
| template<class ApproximateNumber = double> | |
| ApproximateNumber | length () const |
| Returns the Euclidean length. | |
| constexpr auto | lengthL1 () const |
| Returns the Manhattan length. | |
| constexpr auto | lengthLInf () const |
| Returns the Chebyshev length. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | verticesContain (const OtherPoint &point) const |
| Returns whether one endpoint equals the given point. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | containsEndpoint (const OtherPoint &point) const |
| Returns whether the given point is one endpoint. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | boundaryContains (const OtherPoint &point) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | boundaryContains (const OtherSegment &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | boundaryContains (const OtherOrientedSegment &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<LineConcept OtherLine> | |
| constexpr bool | boundaryContains (const OtherLine &) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | boundaryContains (const OtherOrientedLine &) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<RayConcept OtherRay> | |
| constexpr bool | boundaryContains (const OtherRay &) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | boundaryContains (const OtherHalfplane &) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | boundaryContains (const OtherRectangle &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | boundaryContains (const OtherTriangle &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | boundaryContains (const OtherConvex &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | boundaryContains (const OtherPolygon &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | boundaryContains (const OtherDisk &other) const |
| Tests whether this shape's boundary contains the other shape (∂A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | containsCollinear (const OtherPoint &point) const |
| Returns whether the segment contains the given point that is collinear with the segment. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | contains (const OtherPoint &point) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | contains (const OtherSegment &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | contains (const OtherOrientedSegment &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<LineConcept OtherLine> | |
| constexpr bool | contains (const OtherLine &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | contains (const OtherOrientedLine &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<RayConcept OtherRay> | |
| constexpr bool | contains (const OtherRay &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | contains (const OtherHalfplane &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<RectangleConcept OtherRectangle> | |
| constexpr bool | contains (const OtherRectangle &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<TriangleConcept OtherTriangle> | |
| constexpr bool | contains (const OtherTriangle &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<ConvexConcept OtherConvex> | |
| constexpr bool | contains (const OtherConvex &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PolygonConcept OtherPolygon> | |
| constexpr bool | contains (const OtherPolygon &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<DiskConcept OtherDisk> | |
| constexpr bool | contains (const OtherDisk &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | contains (const Shape< OtherPoint > &other) const |
| Tests whether this shape contains the other shape (A ⊇ B). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | boundaryContains (const Shape< OtherPoint > &other) const |
| Tests whether this shape's boundary 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<TriangleConcept OtherTriangle> | |
| constexpr bool | interiorContains (const OtherTriangle &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<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<PointConcept OtherPoint> | |
| constexpr bool | collinear (const OtherPoint &point) const |
| Returns whether the given point lies on the supporting line. | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | collinear (const OtherSegment &other) const |
| Returns whether another segment lies on the same supporting line. | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | collinear (const OtherOrientedSegment &other) const |
| Returns whether an oriented segment lies on the same supporting line. | |
| template<LineConcept OtherLine> | |
| constexpr bool | collinear (const OtherLine &other) const |
| Returns whether a line lies on the same supporting line. | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | collinear (const OtherOrientedLine &other) const |
| Returns whether an oriented line lies on the same supporting line. | |
| template<RayConcept OtherRay> | |
| constexpr bool | collinear (const OtherRay &other) const |
| Returns whether a ray lies on the same supporting line. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr ResultNumber | slope () const |
| Returns the slope of the segment. | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | parallel (const OtherSegment &other) const |
| Returns whether another segment is parallel to this one. | |
| template<OrientedSegmentConcept OtherOrientedSegment> | |
| constexpr bool | parallel (const OtherOrientedSegment &other) const |
| Returns whether an oriented segment is parallel to this one. | |
| template<LineConcept OtherLine> | |
| constexpr bool | parallel (const OtherLine &other) const |
| Returns whether a line is parallel to this segment. | |
| template<OrientedLineConcept OtherOrientedLine> | |
| constexpr bool | parallel (const OtherOrientedLine &other) const |
| Returns whether an oriented line is parallel to this segment. | |
| template<RayConcept OtherRay> | |
| constexpr bool | parallel (const OtherRay &other) const |
| Returns whether a ray is parallel to this segment. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | intersects (const OtherPoint &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | intersects (const OtherSegment &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| constexpr bool | intersects (const Shape< PointType > &other) const |
| Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅). | |
| template<typename OtherShape> requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) | |
| 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<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>, typename OtherShape> requires (!PointConcept<OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& self) { o.template intersection<ResultNumber>(self); }) | |
| constexpr auto | intersection (const OtherShape &other) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = NumberType, class EmptyPoint> | |
| constexpr EmptyShape< EmptyPoint > | intersection (const EmptyShape< EmptyPoint > &) const |
| Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint. | |
| template<class ResultNumber = division_result_t<NumberType>, class OtherNumber> | |
| constexpr std::optional< ResultNumber > | yAtX (const OtherNumber &x) const |
| Returns the value of the y coordinate for a given x, if it exists. | |
| template<class ResultNumber = division_result_t<NumberType>, class OtherNumber> | |
| constexpr std::optional< ResultNumber > | xAtY (const OtherNumber &y) const |
| Returns the value of the x coordinate for a given y, if it exists. | |
| template<PointConcept OtherPoint> | |
| constexpr bool | separates (const OtherPoint &other) 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<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<HalfplaneConcept OtherHalfplane> | |
| constexpr bool | separates (const OtherHalfplane &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). | |
| constexpr bool | separates (const Shape< PointType > &other) const |
| Tests whether removing this shape disconnects the other shape (B∖A is disconnected). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | interiorsIntersect (const OtherPoint &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<typename OtherShape> requires (!PointConcept<OtherShape> && detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) | |
| 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) ≠ ∅). | |
| constexpr bool | interiorsIntersect (const Shape< PointType > &other) const |
| Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅). | |
| template<SegmentConcept OtherSegment> | |
| constexpr bool | crosses (const OtherSegment &other) const |
| Tests whether the two shapes mutually separate each other (each disconnects the other). | |
| template<PointConcept OtherPoint> | |
| constexpr bool | crosses (const 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<Segment>) | |
| 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). | |
| constexpr bool | crosses (const Shape< PointType > &other) 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>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& self) { o.template squaredDistance<ResultNumber>(self); }) | |
| constexpr auto | squaredDistance (const OtherShape &other) const |
| Returns the squared Euclidean distance to the given shape. | |
| template<class ResultNumber = double, class DiskPointType, class DiskLabel> | |
| detail::floating_result_t< ResultNumber > | squaredDistance (const Disk< DiskPointType, DiskLabel > &disk) const |
| Returns the squared Euclidean distance to a disk. | |
| template<class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape> requires detail::ClosestPairConcept<Segment<TPoint, 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<Segment<TPoint, 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>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& self) { o.template distanceL1<ResultNumber>(self); }) | |
| constexpr auto | distanceL1 (const OtherShape &other) const |
| Returns the Manhattan (L1) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | intersection (const Shape< OtherPoint > &other) const |
| Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersection. | |
| template<class ResultNumber = double, PointConcept OtherPoint> | |
| constexpr auto | distanceL1 (const Shape< OtherPoint > &other) const |
| Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceL1. | |
| template<class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint> | |
| constexpr auto | distanceLInf (const OtherPoint &point) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr auto | distanceLInf (const OtherSegment &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& self) { o.template distanceLInf<ResultNumber>(self); }) | |
| constexpr auto | distanceLInf (const OtherShape &other) const |
| Returns the Chebyshev (LInf) distance to the given shape. | |
| template<class ResultNumber = double, PointConcept OtherPoint> | |
| constexpr auto | distanceLInf (const Shape< OtherPoint > &other) const |
| Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceLInf. | |
| template<class 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 = 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>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& 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 distance to the given shape, using symmetry to re-dispatch through the wrapper's own hausdorffDistanceL1. | |
| 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 = 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>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& 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 distance to the given shape, using symmetry to re-dispatch through the wrapper's own hausdorffDistanceLInf. | |
| template<class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment> | |
| constexpr auto | squaredHausdorffDistance (const OtherSegment &other) const |
| Returns the squared Hausdorff distance to another segment. | |
| template<class ResultNumber = NumberType, PointConcept OtherPoint> | |
| constexpr auto | squaredHausdorffDistance (const OtherPoint &point) const |
| Returns the squared Hausdorff distance to a point. | |
| template<class ResultNumber = division_result_t<NumberType>, typename OtherShape> requires ((detail::shapeRank<OtherShape> > detail::shapeRank<Segment>) && requires(const OtherShape& o, const Segment& self) { o.template squaredHausdorffDistance<ResultNumber>(self); }) | |
| constexpr auto | squaredHausdorffDistance (const OtherShape &other) const |
| Returns the squared Hausdorff distance to the given shape. | |
| constexpr Segment | diameter () const |
| Returns a segment defining the diameter. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Point< ResultNumber > | midpoint () const |
| Returns the midpoint of the segment. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Point< ResultNumber > | pointInside () const |
| Returns a point inside the segment. | |
| 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. | |
| template<class ResultNumber = grid_number_t<typename TPoint::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 segment contains. | |
| constexpr Rectangle< PointType > | bbox () const |
| Returns the bounding box of the segment. | |
| template<std::floating_point ResultNumber = double> | |
| constexpr Rectangle< Point< ResultNumber > > | fbox () const |
| Returns a bounding box of the segment with floating point coordinates. | |
| constexpr std::array< PointType, 2 > | vertices () const |
| Returns the two endpoints in canonical order. | |
| constexpr Convex< PointType > | convexHull () const |
| Returns the convex hull of the segment's endpoints. | |
| constexpr std::array< Segment, 1 > | edges () const |
| Returns the unique boundary edge of the segment. | |
| constexpr std::array< OrientedSegment< PointType >, 1 > | orientedEdges () const |
| Returns the unique oriented boundary edge in canonical order. | |
| constexpr Polyline< PointType > | asPolyline () const |
| Returns the segment as a two-vertex polyline. | |
| template<class OtherShape> requires MinkowskiSummableConcept<Segment<TPoint, 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<Segment<TPoint, 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<Segment<TPoint, 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<Segment<TPoint, TLabel>, OtherShape> && (detail::shapeRank<OtherShape> > detail::shapeRank <Segment>) && requires(const OtherShape& o, const Segment& self) { o.template minkowskiSum<ResultNumber>(self); }) | |
| auto | minkowskiSum (const OtherShape &other) const |
| Returns the regularized Minkowski sum of the two shapes (A ⊕ B). | |
| template<PointConcept OtherPoint> | |
| constexpr Segment & | operator+= (const OtherPoint &translation) |
| Translates the segment by the given point in place. | |
| template<PointConcept OtherPoint> | |
| constexpr Segment & | operator-= (const OtherPoint &translation) |
| Translates the segment by the negation of the given point in place. | |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Segment & | operator*= (const Scalar &scalar) |
| Scales the segment around the origin by a scalar in place. | |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Segment & | operator/= (const Scalar &scalar) |
| Divides the segment coordinates by a scalar in place. | |
| template<PointConcept OtherPoint> | |
| constexpr Segment< PointType, LabelType > & | operator+= (const OtherPoint &translation) |
| template<PointConcept OtherPoint> | |
| constexpr Segment< PointType, LabelType > & | operator-= (const OtherPoint &translation) |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Segment< PointType, LabelType > & | operator*= (const Scalar &scalar) |
| template<class Scalar> requires (!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>) | |
| constexpr Segment< PointType, LabelType > & | operator/= (const Scalar &scalar) |
| template<class OtherNumber> | |
| constexpr Segment< PointType, LabelType > | scaledUpX (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Segment< PointType, LabelType > | scaledUpY (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Segment< PointType, LabelType > | scaledDownX (const OtherNumber scalar) const |
| template<class OtherNumber> | |
| constexpr Segment< PointType, LabelType > | scaledDownY (const OtherNumber scalar) const |
Static Public Member Functions | |
| static constexpr std::size_t | size () |
| Returns the number of endpoints (always 2). | |
Unoriented closed segment between two endpoints plus optional segment label.
Unoriented segment connecting two endpoints.
The endpoints are always sorted. The interior of the segment is the segment excluding the endpoints.
A segment may carry an optional LabelType value, independent of the endpoint point label. The label is metadata: it is ignored by equality, ordering and hashing, but it is copied across conversions and preserved by in-place transformations.
| PointType | Endpoint point type. |
| TLabel | Optional label type carried with the segment (NoLabel to omit). |
| using pgl::Segment< TPoint, TLabel >::LabelType = TLabel |
| using pgl::Segment< TPoint, TLabel >::NumberType = PointType::NumberType |
| using pgl::Segment< TPoint, TLabel >::PointType = TPoint |
|
constexprdefault |
Creates the degenerate segment (0,0)--(0,0).
|
inlineconstexpr |
|
inlineconstexpr |
Creates a segment from four coordinates.
| x1 | X coordinate of the first endpoint. |
| y1 | Y coordinate of the first endpoint. |
| x2 | X coordinate of the second endpoint. |
| y2 | Y coordinate of the second endpoint. |
|
inlineconstexpr |
|
inlineconstexpr |
Same as the four-coordinate constructor, and stores a label.
|
inlineconstexpr |
Converts a segment with a different point and/or label type.
The endpoints are converted to PointType and re-sorted, and the label is copied when both sides carry one.
|
nodiscardconstexpr |
Returns the area of the segment.
A segment is one-dimensional, so its area is always zero.
| ResultNumber | Result type (default: NumberType). |
|
inlinenodiscardconstexpr |
Returns the segment as a (degenerate) half-plane intersection.
The region is the segment's supporting-line slab clamped perpendicularly at each endpoint; it has empty interior. A zero-length segment produces the corresponding single-point region.
|
inlinenodiscardconstexpr |
Returns the supporting line.
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns the bounding box of the segment.
|
inlineconstexpr |
Returns an iterator to the first endpoint.
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
For segments, the boundary is exactly the two endpoints.
| OtherPoint | Type of the point. |
| point | Point to test. |
Segment endpoint, boundary, containment, collinearity, intersection, and topological predicates, including the generic separates / crosses dispatch used against 1D and area targets.
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
A boundary has no area, so it holds only a region with no area — which is exactly the union of that region's ring edges.
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
For segments, the boundary is exactly the two endpoints, so this is true iff all vertices of other are endpoints of this segment.
| OtherPoint | Type of the Shape defining points. |
| other | Shape to check. |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
|
inlineconstexpr |
Returns an iterator to the first endpoint.
|
inlineconstexpr |
Returns an iterator past the last endpoint.
|
nodiscardconstexpr |
Returns the pair of points realizing the distance, nothing when the shapes meet.
The first point lies on this shape and the second on other. Empty exactly when squaredDistance is zero. Unlike closestSegments this also takes an unbounded convex other — a line, an oriented line, a ray, a half-plane, a half-plane intersection — which realizes the distance at a point on no edge and at no vertex: there is no element to name there, but there is still a point to give.
| ResultNumber | Coordinate type of the returned points (default: division_result_t). |
ResultNumber it truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
nodiscardconstexpr |
Returns the pair of elements realizing the distance, nothing when the shapes meet.
The first element is this shape's, the second is other's; each is one of the shape's edges, degenerate to a vertex where the shape has none. Empty exactly when squaredDistance is zero.
| ResultNumber | Coordinate type of the returned segments (default: NumberType). |
other's coordinates and labels are re-expressed in this shape's, so a narrower ResultNumber loses them.
|
nodiscardconstexpr |
Returns whether a line lies on the same supporting line.
|
nodiscardconstexpr |
Returns whether an oriented line lies on the same supporting line.
|
nodiscardconstexpr |
Returns whether an oriented segment lies on the same supporting line.
| OtherPoint | Type of the other segment endpoints. |
| other | Other oriented segment. |
|
nodiscardconstexpr |
Returns whether the given point lies on the supporting line.
| OtherPoint | Type of the point. |
| point | Point to test. |
|
nodiscardconstexpr |
Returns whether a ray lies on the same supporting line.
|
nodiscardconstexpr |
Returns whether another segment lies on the same supporting line.
| OtherPoint | Type of the other segment endpoints. * |
| other | Other segment. |
|
inlinenodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Complexity: O(log n) for a convex polygon with n vertices.
| OtherPoint | Type of the convex polygon defining points. |
| other | Convex polygon to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the disk boundary points. |
| OtherLabel | Label type of the disk. |
| other | Disk to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the halfplane defining points. |
| other | Halfplane to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the line defining points. |
| other | Line to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the oriented line defining points. |
| other | Oriented line to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the other segment endpoints. |
| other | Other oriented segment. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
Endpoints are included.
| OtherPoint | Type of the point. |
| point | Point to test. |
Segment endpoint, boundary, containment, collinearity, intersection, and topological predicates, including the generic separates / crosses dispatch used against 1D and area targets.
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the ray defining points. |
| other | Ray to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the rectangle defining points. |
| other | Rectangle to check. |
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
A region is contained exactly when its outer polygon is: the region holds the whole outer ring whatever its holes do, and this shape has a connected complement. See implementation/contains.hpp.
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the other segment endpoints. |
| other | Other segment. |
|
inlinenodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape contains the other shape (A ⊇ B).
| OtherPoint | Type of the triangle defining points. |
| other | Triangle to check. |
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns whether the segment contains the given point that is collinear with the segment.
Endpoints are included. Undefined behavior if the point is not collinear with the segment.
| OtherPoint | Type of the point. |
| point | Point to test. |
|
nodiscardconstexpr |
Returns whether the given point is one endpoint.
This is a segment-specific alias for verticesContain.
| OtherPoint | Type of the point. |
| point | Point to test. |
|
inlinenodiscardconstexpr |
Returns the convex hull of the segment's endpoints.
|
inlinenodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
Two segments cross if they intersect at a single point that is not an endpoint of either segment. Equivalently, two segments s,t cross if s separates t and t separates s. Performs at most 4 orientation tests.
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
Segment endpoint, boundary, containment, collinearity, intersection, and topological predicates, including the generic separates / crosses dispatch used against 1D and area targets.
|
inlinenodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Tests whether the two shapes mutually separate each other (each disconnects the other).
|
nodiscardconstexpr |
Returns a segment defining the diameter.
For a segment, the diameter is the segment itself.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
ResultNumber the exact distance is generally a fraction for a non-axis-aligned segment, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
nodiscardconstexpr |
Returns the Manhattan (L1) distance to the given shape.
ResultNumber the exact distance is generally a fraction for a non-axis-aligned segment, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
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.
|
inlinenodiscardconstexpr |
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceL1.
Distance is symmetric, so this just calls other's own distanceL1, which visits its wrapped alternative and throws if the pair is unsupported.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
ResultNumber the exact distance is generally a fraction for a non-axis-aligned segment, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) distance to the given shape.
ResultNumber the exact distance is generally a fraction for a non-axis-aligned segment, so the internal division truncates. Request a floating-point or pgl::Rational result type for an accurate value.
|
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.
|
inlinenodiscardconstexpr |
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own distanceLInf.
Distance is symmetric, so this just calls other's own distanceLInf, which visits its wrapped alternative and throws if the pair is unsupported.
|
nodiscardconstexpr |
Returns the unique boundary edge of the segment.
|
inlineconstexpr |
Returns an iterator past the last endpoint.
|
nodiscardconstexpr |
Returns a bounding box of the segment with floating point coordinates.
| ResultNumber | Floating point type |
|
inlineconstexpr |
Cyclic access: same as operator[] but index is taken modulo size(); negative indices wrap from the end.
|
nodiscardconstexpr |
Returns the point the segment collapses to, if it does.
Complexity: O(1).
|
nodiscardconstexpr |
Returns the Manhattan (L1) Hausdorff distance to the given shape.
|
nodiscardconstexpr |
Returns the Manhattan (L1) Hausdorff distance to the given shape.
|
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.
|
inlinenodiscardconstexpr |
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own hausdorffDistanceL1.
Distance is symmetric, so this just calls other's own hausdorffDistanceL1, which visits its wrapped alternative and throws if the pair is unsupported.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
|
nodiscardconstexpr |
Returns the Chebyshev (LInf) Hausdorff distance to the given shape.
|
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.
|
inlinenodiscardconstexpr |
Returns the distance to the given shape, using symmetry to re-dispatch through the wrapper's own hausdorffDistanceLInf.
Distance is symmetric, so this just calls other's own hausdorffDistanceLInf, which visits its wrapped alternative and throws if the pair is unsupported.
|
inlineconstexpr |
Returns the smallest index i with (*this)[i] == point, or -1 if no endpoint equals point.
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
| OtherPoint | Type of the other oriented segment endpoints. |
| other | Other oriented segment. |
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
| OtherPoint | Type of the point. |
| point | Point to check. |
Segment endpoint, boundary, containment, collinearity, intersection, and topological predicates, including the generic separates / crosses dispatch used against 1D and area targets.
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
| OtherPoint | Type of the other segment endpoints. |
| other | Other segment. |
|
inlinenodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
| OtherPoint | Type of the triangle defining points. |
| other | Triangle to check. |
|
nodiscardconstexpr |
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
|
inlinenodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
nodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
Performs at most 4 orientation tests.
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
Segment endpoint, boundary, containment, collinearity, intersection, and topological predicates, including the generic separates / crosses dispatch used against 1D and area targets.
|
nodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
inlinenodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
nodiscardconstexpr |
Tests whether the interiors of the two shapes intersect ((A∖∂A) ∩ (B∖∂B) ≠ ∅).
|
inlinenodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
The intersection of two segments may be null, a point, or a segment. Hence, we return an std::optional of std::variant of point and segment. Division is only used if the segments cross.
| ResultNumber | Number type of the return value. |
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
|
nodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
|
inlinenodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
|
inlinenodiscardconstexpr |
Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersection.
An intersection is symmetric, so this just calls other's own intersection, which visits its wrapped alternative and throws if the pair is unsupported.
The point type is deduced from other so a plain concrete shape cannot reach this overload through an implicit conversion to Shape.
other holds is not known until run time, so neither is the result's.
|
inlinenodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Performs at most 4 orientation tests.
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
|
inlinenodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
nodiscardconstexpr |
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns whether the segment is horizontal.
|
nodiscardconstexpr |
Returns whether the segment collapses to a single point.
Equivalent to isDegenerate for a segment, which always has two defining points.
Complexity: O(1).
|
nodiscardconstexpr |
Returns whether the segment is degenerate without collapsing to a point or to a segment.
A segment is never undefined: its only degeneracy is collapsing to a point, so this always returns false. Provided for uniformity with the other shapes.
Complexity: O(1).
|
nodiscardconstexpr |
Returns whether the segment is vertical.
|
inlineconstexpr |
Returns the segment label.
The label is mutable even through a const segment: it is metadata that does not participate in equality, hashing, or geometric predicates.
|
nodiscard |
Returns the integer points the segment contains.
The lattice points lie on the segment in order, from min to max, spaced by the primitive integer direction of the segment. An endpoint is among them exactly when it is a lattice point itself, so integer endpoints always are and fractional ones never are – a segment over non-integer coordinates still contains every grid point it passes through, and one whose supporting line misses the grid contains none.
A vertical or horizontal segment, a single point included, is answered from the integers of one interval, with no direction to reduce and no fraction to solve. Any other segment over integer coordinates costs one gcd; over fractional ones it solves for a lattice point on its supporting line, exactly and at the price of an extended gcd.
| ResultNumber | Integer coordinate type of the points: the segment's own coordinate type when that is a signed integer, the integer a pgl::Rational is built on, and int64_t for anything else. |
| std::logic_error | If a coordinate is not finite, or a lattice point of the segment does not fit ResultNumber. |
| std::length_error | If there are more of them than a vector holds. |
|
nodiscard |
Returns the Euclidean length.
| ApproximateNumber | Floating-point return type. |
|
nodiscardconstexpr |
Returns the Manhattan length.
|
nodiscardconstexpr |
Returns the Chebyshev length.
|
inlineconstexpr |
Returns the largest stored endpoint.
|
nodiscardconstexpr |
Returns the midpoint of the segment.
| ResultNumber | Coordinate type of the midpoint. |
|
inlineconstexpr |
Returns the smallest stored endpoint.
|
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.
| OtherShape | Type of the shape to erode by. |
| other | Shape to erode by. |
other covers no point.
|
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 segment erodes to the sub-segment of itself the operand's width leaves.
Eroding by a shape that covers no point is the whole plane, which a HalfplaneIntersection returns and the tighter result types cannot.
| OtherShape | Type of the shape to erode by. |
| other | Shape to erode by. |
|
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, PolygonWithHoles and Polyline. Forwards to the other shape's implementation so that each unordered pair needs the sum defined only once, on the higher-ranked shape.
|
nodiscardconstexpr |
Returns the Minkowski sum of this shape and another (A ⊕ B).
The sum is the point set {a + b : a ∈ A, b ∈ B}. Summing with a Point is a translation, so it returns this shape's own type; two bounded convex shapes sum to a Convex, or to a Rectangle when both are rectangles. See MinkowskiSummableConcept for the pairs a Minkowski sum is defined for.
| OtherShape | Type of the other shape. |
| other | Shape to sum with. |
|
explicitnodiscardconstexpr |
Converts to the supporting unoriented line.
Direct initialization and explicit casts are allowed once Line is available.
|
constexpr |
|
constexpr |
Scales the segment around the origin by a scalar in place.
|
constexpr |
|
constexpr |
Translates the segment by the given point in place.
|
constexpr |
|
constexpr |
Translates the segment by the negation of the given point in place.
|
constexpr |
|
constexpr |
Divides the segment coordinates by a scalar in place.
|
inlineconstexpr |
|
inlineconstexpr |
Assigns from a segment with compatible point and label types.
|
inlineconstexpr |
Compares two segments by their endpoints; the label is ignored.
| other | Segment to compare with. |
|
inlineconstexpr |
Returns endpoint 0 or 1.
| index | Endpoint index. |
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns whether a line is parallel to this segment.
| OtherPoint | Type of the other segment endpoints. |
| other | Other line. |
|
nodiscardconstexpr |
Returns whether an oriented line is parallel to this segment.
| OtherNumber | Coordinate type of the line defining points. |
| OtherPoint::LabelType | Label type of the line defining points. |
| other | Other oriented line. |
|
nodiscardconstexpr |
Returns whether an oriented segment is parallel to this one.
| OtherPoint | Type of the other segment endpoints. |
| other | Other oriented segment. |
|
nodiscardconstexpr |
Returns whether a ray is parallel to this segment.
| OtherNumber | Coordinate type of the ray defining points. |
| OtherPoint::LabelType | Label type of the ray defining points. |
| other | Other ray. |
|
nodiscardconstexpr |
Returns whether another segment is parallel to this one.
| OtherPoint | Type of the other segment endpoints. |
| other | Other segment. |
|
nodiscardconstexpr |
Returns a point inside the segment.
For a segment, this is its midpoint.
| ResultNumber | Coordinate type of the midpoint. |
|
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.
|
constexpr |
Rotates the segment by 90k degrees around the origin in place.
Endpoints are re-normalized after rotation.
| k | Number of 90-degree CCW rotations (may be negative). |
|
nodiscardconstexpr |
Returns the segment rotated by 90k degrees around the origin.
Endpoints are re-normalized after rotation.
| k | Number of 90-degree CCW rotations (may be negative). |
|
nodiscardconstexpr |
Tests whether another shape defines exactly the same point set.
|
constexpr |
|
nodiscardconstexpr |
Returns the segment with its x-coordinates divided by a divisor.
|
constexpr |
|
nodiscardconstexpr |
Returns the segment with its y-coordinates divided by a divisor.
|
constexpr |
Divides the segment's x-coordinates by a divisor in place.
|
constexpr |
Divides the segment's y-coordinates by a divisor in place.
|
constexpr |
|
nodiscardconstexpr |
Returns the segment with its x-coordinates multiplied by a factor.
|
constexpr |
|
nodiscardconstexpr |
Returns the segment with its y-coordinates multiplied by a factor.
|
constexpr |
Multiplies the segment's x-coordinates by a factor in place.
|
constexpr |
Multiplies the segment's y-coordinates by a factor in place.
|
inlinenodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Walks the polygon boundary once and counts its contacts with the segment: each is either a maximal run of boundary vertices lying on the segment, or an edge that cuts transversally through the segment's interior. Two such contacts mean the segment carries a chord clear across the polygon, so removing it splits the polygon in two.
Complexity: O(n) for n polygon vertices.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscard |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
The region is settled by the cell engine of implementation/separates.hpp; see the notes on pgl::PolygonWithHoles::separates for what a region admits that a simply connected target does not.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Tests whether the this segment intersects the other segment in a single point that is not an endpoint of the other segment. Performs at most 4 orientation tests.
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
|
nodiscard |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
A set of regions is the one target that may already be in several pieces before anything is removed, so this neither folds over its components nor answers false for a remover that misses it. See implementation/separates.hpp.
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
nodiscardconstexpr |
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
|
inlinestaticconstexpr |
Returns the number of endpoints (always 2).
|
nodiscardconstexpr |
Returns the slope of the segment.
Undefined behavior for vertical segments.
| ResultNumber | Coordinate type of the returned slope. |
|
inlinenodiscard |
Returns the squared Euclidean distance to a disk.
Forwards to Disk::squaredDistance. Reports in detail::floating_result_t<ResultNumber>: a distance realized on a circle is generally irrational, so a floating-point ResultNumber is honoured as asked and any other request falls back to double.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
The computation uses a projection on the supporting line and divides by the squared segment length when the closest point lies in the interior.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
| OtherPoint | Type of the point. |
| point | Point to measure from. |
ResultNumber the exact squared distance is generally a fraction, so the internal division truncates and the result is inexact. Request a floating-point or pgl::Rational result type, e.g. squaredDistance<double>(point), for an accurate value.
|
nodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
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>(other), for an accurate value.
|
inlinenodiscardconstexpr |
Returns the squared Euclidean distance to the given shape.
Forwards to the other shape's implementation so that each unordered pair needs squaredDistance defined only once, on the higher-ranked shape.
|
nodiscardconstexpr |
Returns the squared Hausdorff distance to a point.
| ResultNumber | Coordinate type of the returned distance (default: NumberType). |
| OtherPoint | Type of the point. |
| point | Point to measure from. |
|
nodiscardconstexpr |
Returns the squared Hausdorff distance to another segment.
Since the distance to a segment is convex along a segment, the directed Hausdorff distance is attained at an endpoint.
| ResultNumber | Coordinate type of the returned distance (default: division_result_t). |
| OtherNumber | Coordinate type of the other segment endpoints. |
| OtherPoint::LabelType | Label type of the other segment endpoints. |
| other | Other segment. |
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. squaredHausdorffDistance<double>(other), for an accurate value.
|
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.
|
nodiscardconstexpr |
Returns the squared Euclidean length.
|
nodiscardconstexpr |
Returns twice the area of the segment.
A segment is one-dimensional, so this is always zero.
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Returns whether one endpoint equals the given point.
| OtherPoint | Type of the point. |
| point | Point to test. |
|
nodiscardconstexpr |
Returns the value of the x coordinate for a given y, if it exists.
Evaluates the x-coordinate of a segment at a given y-coordinate.
If the segment is horizontal at the given coordinate y, then we return the min x coordinate.
| ResultNumber | Number type of the return value. |
| OtherNumber | Coordinate type of the y coordinate. |
| y | Given y coordinate. |
The value is returned only when y lies within the segment's vertical extent. Endpoints are handled exactly.
| ResultNumber | Return coordinate type. |
| OtherNumber | Query y-coordinate type. |
| y | Query y-coordinate. |
|
nodiscardconstexpr |
Returns the value of the y coordinate for a given x, if it exists.
Evaluates the y-coordinate of a segment at a given x-coordinate.
If the segment is vertical at the given coordinate x, then we return the min y coordinate.
| ResultNumber | Number type of the return value. |
| OtherNumber | Coordinate type of the x coordinate. |
| x | Given x coordinate. |
The value is returned only when x lies within the segment's horizontal extent. Endpoints are handled exactly.
| ResultNumber | Return coordinate type. |
| OtherNumber | Query x-coordinate type. |
| x | Query x-coordinate. |