hgeometry-0.6.0.0: Geometric Algorithms, Data structures, and Data types.

Safe HaskellNone
LanguageHaskell2010

Algorithms.Geometry.LineSegmentIntersection.BentleyOttmann

Contents

Synopsis

Documentation

intersections :: (Ord r, Fractional r) => [LineSegment 2 p r] -> Intersections p r Source #

Compute all intersections

\(O((n+k)\log n)\), where \(k\) is the number of intersections.

merge :: Ord r => [IntersectionPoint p r] -> Intersections p r Source #

Group the segments with the intersection points

groupStarts :: Eq r => [Event p r] -> [Event p r] Source #

Group the startpoints such that segments with the same start point correspond to one event.

Data type for Events

data EventType s Source #

Type of segment

Constructors

Start !(NonEmpty s) 
Intersection 
End !s 

Instances

data Event p r Source #

The actual event consists of a point and its type

Constructors

Event 

Fields

Instances

Eq r => Eq (Event p r) Source # 

Methods

(==) :: Event p r -> Event p r -> Bool #

(/=) :: Event p r -> Event p r -> Bool #

Ord r => Ord (Event p r) Source # 

Methods

compare :: Event p r -> Event p r -> Ordering #

(<) :: Event p r -> Event p r -> Bool #

(<=) :: Event p r -> Event p r -> Bool #

(>) :: Event p r -> Event p r -> Bool #

(>=) :: Event p r -> Event p r -> Bool #

max :: Event p r -> Event p r -> Event p r #

min :: Event p r -> Event p r -> Event p r #

(Show p, Show r) => Show (Event p r) Source # 

Methods

showsPrec :: Int -> Event p r -> ShowS #

show :: Event p r -> String #

showList :: [Event p r] -> ShowS #

ordPoints :: Ord r => Point 2 r -> Point 2 r -> Ordering Source #

An ordering that is decreasing on y, increasing on x

startSegs :: Event p r -> [LineSegment 2 p r] Source #

Get the segments that start at the given event point

ordAtNav :: (Ord r, Fractional r) => r -> TreeNavigator r (LineSegment 2 p r) Source #

The navigator that we use that orders the segments that intersect at a horizontal line (from left to right)

The Main Sweep

type EventQueue p r = Set (Event p r) Source #

sweep :: (Ord r, Fractional r) => EventQueue p r -> StatusStructure p r -> [IntersectionPoint p r] Source #

Run the sweep handling all events

handle :: (Ord r, Fractional r) => Event p r -> EventQueue p r -> StatusStructure p r -> [IntersectionPoint p r] Source #

Handle an event point

extractContains :: (Fractional r, Ord r) => Point 2 r -> StatusStructure p r -> (StatusStructure p r, [LineSegment 2 p r], StatusStructure p r) Source #

split the status structure, extracting the segments that contain p. the result is (before,contains,after)

toStatusStruct :: (Fractional r, Ord r) => Point 2 r -> [LineSegment 2 p r] -> StatusStructure p r Source #

Given a point and the linesegements that contain it. Create a piece of status structure for it.

rightEndpoint :: Ord r => LineSegment 2 p r -> r Source #

Get the right endpoint of a segment

endsAt :: Ord r => Point 2 r -> LineSegment 2 p r -> Bool Source #

Test if a segment ends at p

Finding New events

findNewEvent :: (Ord r, Fractional r) => Point 2 r -> LineSegment 2 p r -> LineSegment 2 p r -> Maybe (Event p r) Source #

Find all events