Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
HGeometry.LineSegment.Intersection.BentleyOttmann
Description
The \(O((n+k)\log n)\) time line segment intersection algorithm by Bentley and Ottmann.
Synopsis
- intersections :: forall lineSegment point r f. (LineSegment_ lineSegment point, Point_ point 2 r, Eq lineSegment, Ord r, Fractional r, HasOnSegment lineSegment 2, IntersectConstraints lineSegment, Foldable f, Functor f, StartPointOf lineSegment ~ EndPointOf lineSegment) => f lineSegment -> Intersections r lineSegment
- interiorIntersections :: (LineSegment_ lineSegment point, Point_ point 2 r, Eq lineSegment, Ord r, Fractional r, IntersectConstraints lineSegment, StartPointOf lineSegment ~ EndPointOf lineSegment, HasOnSegment lineSegment 2, Foldable f, Functor f) => f lineSegment -> Intersections r lineSegment
- type Intersections r lineSegment = Map (Point 2 r) (Associated lineSegment)
- intersectionPoints :: Intersections r lineSegment -> Set (Point 2 r)
- data Associated lineSegment
- startPointOf :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundStart lineSegment))
- endPointOf :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundEnd lineSegment))
- interiorTo :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundIntersection lineSegment))
- associatedSegments :: Fold (Associated lineSegment) lineSegment
- data AroundEnd a
- data AroundStart a
- data AroundIntersection a
- isInteriorIntersection :: Associated lineSegment -> Bool
- data IntersectionPoint point lineSegment
- intersectionPointOf :: (LineSegment_ lineSegment point, Point_ point 2 r, Ord r, Fractional r, IntersectConstraints lineSegment) => lineSegment -> lineSegment -> Maybe (IntersectionPoint (Point 2 r) lineSegment)
- intersectionPoint :: forall point lineSegment point. Lens (IntersectionPoint point lineSegment) (IntersectionPoint point lineSegment) point point
- associatedSegs :: forall point lineSegment lineSegment. Lens (IntersectionPoint point lineSegment) (IntersectionPoint point lineSegment) (Associated lineSegment) (Associated lineSegment)
- type IntersectConstraints lineSegment = (OrdArounds lineSegment, IsIntersectableWith lineSegment lineSegment, Intersection lineSegment lineSegment ~ Maybe (LineSegmentLineSegmentIntersection lineSegment))
- type OrdArounds lineSegment = (Ord (AroundStart lineSegment), Ord (AroundIntersection lineSegment), Ord (AroundEnd lineSegment))
Documentation
intersections :: forall lineSegment point r f. (LineSegment_ lineSegment point, Point_ point 2 r, Eq lineSegment, Ord r, Fractional r, HasOnSegment lineSegment 2, IntersectConstraints lineSegment, Foldable f, Functor f, StartPointOf lineSegment ~ EndPointOf lineSegment) => f lineSegment -> Intersections r lineSegment Source #
Compute all intersections
\(O((n+k)\log n)\), where \(k\) is the number of intersections.
interiorIntersections :: (LineSegment_ lineSegment point, Point_ point 2 r, Eq lineSegment, Ord r, Fractional r, IntersectConstraints lineSegment, StartPointOf lineSegment ~ EndPointOf lineSegment, HasOnSegment lineSegment 2, Foldable f, Functor f) => f lineSegment -> Intersections r lineSegment Source #
Computes all intersection points p s.t. p lies in the interior of at least one of the segments.
\(O((n+k)\log n)\), where \(k\) is the number of intersections.
type Intersections r lineSegment = Map (Point 2 r) (Associated lineSegment) Source #
For each intersection point the segments intersecting there.
intersectionPoints :: Intersections r lineSegment -> Set (Point 2 r) Source #
Get the set of all intersection points
data Associated lineSegment Source #
The line segments that contain a given point p may either have p as the endpoint or have p in their interior.
if somehow the segment is degenerate, and p is both the start and end it is reported only as the start point.
Instances
startPointOf :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundStart lineSegment)) Source #
endPointOf :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundEnd lineSegment)) Source #
interiorTo :: forall lineSegment. Lens' (Associated lineSegment) (Set (AroundIntersection lineSegment)) Source #
associatedSegments :: Fold (Associated lineSegment) lineSegment Source #
Fold over the segments associated with the intersection.
Assumes that two segments have the same end point
Instances
data AroundStart a Source #
Assumes that two segments have the same start point
Instances
data AroundIntersection a Source #
Assumes that two segments intersect in a single point.
Instances
isInteriorIntersection :: Associated lineSegment -> Bool Source #
Reports whether this associated has any interior intersections
\(O(1)\)
data IntersectionPoint point lineSegment Source #
An intersection point together with all segments intersecting at this point.
Instances
Generic (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types Associated Types type Rep (IntersectionPoint point lineSegment) :: Type -> Type # Methods from :: IntersectionPoint point lineSegment -> Rep (IntersectionPoint point lineSegment) x # to :: Rep (IntersectionPoint point lineSegment) x -> IntersectionPoint point lineSegment # | |
(Read lineSegment, Read point, OrdArounds lineSegment) => Read (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types Methods readsPrec :: Int -> ReadS (IntersectionPoint point lineSegment) # readList :: ReadS [IntersectionPoint point lineSegment] # readPrec :: ReadPrec (IntersectionPoint point lineSegment) # readListPrec :: ReadPrec [IntersectionPoint point lineSegment] # | |
(Show point, Show lineSegment) => Show (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types Methods showsPrec :: Int -> IntersectionPoint point lineSegment -> ShowS # show :: IntersectionPoint point lineSegment -> String # showList :: [IntersectionPoint point lineSegment] -> ShowS # | |
(NFData point, NFData lineSegment) => NFData (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types Methods rnf :: IntersectionPoint point lineSegment -> () # | |
(Eq (AroundStart lineSegment), Eq (AroundIntersection lineSegment), Eq (AroundEnd lineSegment), Eq point) => Eq (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types Methods (==) :: IntersectionPoint point lineSegment -> IntersectionPoint point lineSegment -> Bool # (/=) :: IntersectionPoint point lineSegment -> IntersectionPoint point lineSegment -> Bool # | |
type Rep (IntersectionPoint point lineSegment) Source # | |
Defined in HGeometry.LineSegment.Intersection.Types type Rep (IntersectionPoint point lineSegment) = D1 ('MetaData "IntersectionPoint" "HGeometry.LineSegment.Intersection.Types" "hgeometry-1.0.0.0-inplace" 'False) (C1 ('MetaCons "IntersectionPoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "_intersectionPoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 point) :*: S1 ('MetaSel ('Just "_associatedSegs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Associated lineSegment)))) |
intersectionPointOf :: (LineSegment_ lineSegment point, Point_ point 2 r, Ord r, Fractional r, IntersectConstraints lineSegment) => lineSegment -> lineSegment -> Maybe (IntersectionPoint (Point 2 r) lineSegment) Source #
Given two segments, compute an IntersectionPoint representing their intersection (if such an intersection exists).
intersectionPoint :: forall point lineSegment point. Lens (IntersectionPoint point lineSegment) (IntersectionPoint point lineSegment) point point Source #
associatedSegs :: forall point lineSegment lineSegment. Lens (IntersectionPoint point lineSegment) (IntersectionPoint point lineSegment) (Associated lineSegment) (Associated lineSegment) Source #
type IntersectConstraints lineSegment = (OrdArounds lineSegment, IsIntersectableWith lineSegment lineSegment, Intersection lineSegment lineSegment ~ Maybe (LineSegmentLineSegmentIntersection lineSegment)) Source #
Shorthand for the more-or-less standard constraints that we need on LineSegments
type OrdArounds lineSegment = (Ord (AroundStart lineSegment), Ord (AroundIntersection lineSegment), Ord (AroundEnd lineSegment)) Source #