Sprotty
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Function.Run Sweep

sprotty / runSweep

Function: runSweep()

runSweep(eventQueue): Intersection[]

Defined in: packages/sprotty/src/features/edge-intersection/sweepline.ts:125

Performs the main sweep algorithm on the specified event queue.

An empty priority queue is created to store segments encountered. An item is removed from the priority queue if the vertex is the left endpoint of a segment, we test it against every other segment in the segment queue for intersections with any intersection recorded. We then add the vertex (and it’s associated right endpoint) to the segment queue. If we encounter a right endpoint we remove the first item from the segment queue.

Each pair of segments are only tested once. And only segments that overlap on the x plane are tested against each other.

Parameters

eventQueue

TinyQueue<SweepEvent>

the event queue.

Returns

Intersection[]

the identified intersections.