lecture: line segment intersection and subdivisionsand sis the line segment that ends at p: 1.search...

70
1/69 Geometric Algorithms Lecture: Line segment intersection for map overlay Subdivisions

Upload: others

Post on 11-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

1/69

Geometric Algorithms

Lecture:

Line segment intersection for map overlay

Subdivisions

Page 2: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

2/69Map layers

In a geographic information system(GIS) data is stored in separatelayers

A layer stores the geometricinformation about some theme, likeland cover, road network,municipality boundaries, red foxhabitat, . . .

Page 3: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

3/69Map overlay

Map overlay is the combination oftwo (or more) map layers

It is needed to answer questionslike:

I What is the total length of roadsthrough forests?

I What is the total area of cornfields within 1km from a river?

Page 4: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

4/69Map overlay

To solve map overlay questions, weneed (at the least) intersectionpoints from two sets of linesegments (possibly, boundaries ofregions)

Page 5: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

5/69The (easy) problem

Let’s first look at the easiestversion of the problem:

Where did the caribous crossroads?

Given a set of of n linesegments in the plane, find allintersection points efficiently

Page 6: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

6/69An easy, optimal algorithm?

Algorithm FINDINTERSECTIONS(S)Input. A set S of line segments in the plane.Output. The set of intersection points among the segments in S.1. for each pair of line segments ei,e j ∈ S2. do if ei and e j intersect3. then report their intersection point

Question: Why can we say that this algorithm is optimal?

Page 7: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

7/69

Page 8: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

8/69Output-sensitive algorithm

The asymptotic running time of analgorithm is always input-sensitive(depends on n)

We may also want the running timeto be output-sensitive: if the outputis large, it is fine to spend a lot oftime, but if the output is small, wewant a fast algorithm

Page 9: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

9/69Intersection points in practice

Question: How many intersectionpoints do we typically expect in ourapplications?

If this number is k, and if k = O(n), itwould be nice if the algorithm runsin O(n logn) time

Page 10: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

10/69First attempt

Observation: Two line segments canonly intersect if their y-spans havean overlap

So, how about only testing pairs ofline segments that intersect in they-projection?

1-D problem: Given a set of intervalson the real line, find all partlyoverlapping pairs

x

y

s1 s2s3 s4 s5 s6

(s1, s2), (s4, s6), (s5, s6)

Page 11: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

11/69Second attempt

Refined observation: Two linesegments can only intersect if theiry-spans have an overlap, and theyare adjacent in the x-order at thaty-coordinate (they are horizontalneighbors)

Page 12: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

12/69Plane sweep

The plane sweep technique: Imagine a horizontal linepassing over the plane from top to bottom, solving theproblem as it moves

I The sweep line stops and the algorithm computes atcertain positions⇒ events

I The algorithm stores the relevant situation at the currentposition of the sweep line⇒ status

I The algorithm knows everything it needs to know abovethe sweep line, and found all intersection points

Page 13: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

13/69Sweep

computed

unexplored

Page 14: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

14/69Sweep and status

computed

unexplored

status

Page 15: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

15/69Status and events

The status of this particular plane sweep algorithm, at thecurrent position of the sweep line, is the set of line segmentsintersecting the sweep line, ordered from left to right

The events occur when the status changes, and when outputis generated

event≈ interesting y-coordinate

Page 16: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

16/69

s1

s2s3

s4

s6

s5

s7

s8

add s1

Page 17: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

17/69

s1

s2s3

s4

s6

s5

s7

s8

add s2 after s1

Page 18: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

18/69

s1

s2s3

s4

s6

s5

s7

s8

add s3 between s1and s2

Page 19: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

19/69

s1

s2s3

s4

s6

s5

s7

s8

add s4 before s1

Page 20: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

20/69

s1

s2s3

s4

s6

s5

s7

s8

reportintersection(s1,s2); swap s1and s3

Page 21: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

21/69

s1

s2s3

s4

s6

s5

s7

s8

remove s2

Page 22: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

22/69

s1

s2s3

s4

s6

s5

s7

s8

remove s1

Page 23: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

23/69

s1

s2s3

s4

s6

s5

s7

s8

add s5

Page 24: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

24/69

s1

s2s3

s4

s6

s5

s7

s8

reportintersection(s3,s4); swap s3and s4

Page 25: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

25/69

. . . and so on . . .

Page 26: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

26/69The events

When do the events happen? When the sweep line is

I at an upper endpoint of a line segmentI at a lower endpoint of a line segmentI at an intersection point of a line segment

At each type, the status changes; at the third type output isfound too

Page 27: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

27/69Assume no degenerate cases

We will at first exclude degenerate cases:

I No two endpoints have the samey-coordinate

I No more than two line segmentsintersect in a point

I . . .

Question: Are there more degeneratecases?

Page 28: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

28/69Event list and status structure

The event list is an abstract data structure that stores allevents in the order in which they occur

The status structure is an abstract data structure thatmaintains the current status

Here: The status is the subset of currently intersected linesegments in the order of intersection by the sweep line

Page 29: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

29/69Status structure

We use a balanced binary search tree with the line segmentsin the leaves as the status structure

s1 s2s3 s4 s5 s6

s7s8

s1

s2

s3

s4

s5

s6

s7

s1 s2 s3 s4 s5 s6 s7 s8

Page 30: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

30/69Status structure

s1 s2s3 s4 s5 s6

s7s8

s1

s2

s3

s4

s5

s6

s7

s1 s2 s3 s4 s5 s6 s7 s8

s9

Upper endpoint: search, and insert

Page 31: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

31/69Status structure

s1 s2s3 s4 s5 s6

s7s8

s1

s2

s3

s4

s5

s6

s7

s1 s2 s3 s4 s5 s6 s7 s8

s9

Upper endpoint: search, and insert

Page 32: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

32/69Status structure

s1 s2s3 s4 s5 s6

s7s8

s1

s2

s3

s4

s5

s6

s7

s1 s2

s3

s4 s5 s6 s7 s8

s9

s9

s9

Upper endpoint: search, and insert

Page 33: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

33/69Status structure

Sweep line reaches lower endpoint of a line segment: deletefrom the status structure

Sweep line reaches intersection point: swap two leaves in thestatus structure (and update information on the search paths)

Page 34: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

34/69Finding events

Before the sweep algorithm starts, we know all upperendpoint events and all lower endpoint events

But: How do we know intersection point events???(those we were trying to find . . .)

Recall: Two line segments can only intersect if they arehorizontal neighbors

Page 35: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

35/69Finding events

Lemma: Two line segments si and s j canonly intersect after (= below) they havebecome horizontal neighbors

Proof: Just imagine that the sweep line isever so slightly above the intersectionpoint of si and s j, but below any otherevent �

Also: some earlier (= higher) event madesi and s j horizontally adjacent!!!

sisj

sisj

Page 36: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

36/69Event list

The event list must be a balanced binary search tree, becauseduring the sweep, we discover new events that will happenlater and we want to be able to test whether an event isalready in the list

We know upper endpoint events and lower endpoint eventsbeforehand; we find intersection point events when theinvolved line segments become horizontal neighbors

Page 37: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

37/69Structure of sweep algorithm

Algorithm FINDINTERSECTIONS(S)Input. A set S of line segments in the plane.Output. The intersection points of the segments in S, with for

each intersection point the segments that contain it.1. Initialize an empty event queue Q. Next, insert the

segment endpoints into Q; when an upper endpoint isinserted, the corresponding segment should be storedwith it

2. Initialize an empty status structure T3. while Q is not empty4. do Determine next event point p in Q and delete it5. HANDLEEVENTPOINT(p)

Page 38: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

38/69Event handling

If the event is an upper endpoint event,and s is the line segment that starts atp:

1. Search with p in T , and insert s

2. If s intersects its left neighbor inT , then determine the intersectionpoint and insert it Q

3. If s intersects its right neighbor inT , then determine the intersectionpoint and insert it Q

p

s

Page 39: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

39/69Event handling

If the event is a lower endpoint event,and s is the line segment that ends atp:

1. Search with p in T , and delete s

2. Let sl and sr be the left and rightneighbors of s in T (beforedeletion). If they intersect belowthe sweep line, then insert theirintersection point as an event in Q

p

s

Page 40: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

40/69Event handling

If the event is an intersection pointevent where s and s′ intersect at p:

1. . . .

2. . . .

3. . . .

4. . . .

p

s s′

Page 41: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

41/69Event handling

If the event is an intersection pointevent where s and s′ intersect at p:

1. Exchange s and s′ in T

2. . . .

3. . . .

4. . . .

p

s s′

Page 42: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

42/69Event handling

If the event is an intersection pointevent where s and s′ intersect at p:

1. Exchange s and s′ in T

2. If s′ and its new left neighbor inT intersect below the sweepline, then insert thisintersection point in Q

3. . . .

4. . . .

p

s s′

Page 43: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

43/69Event handling

If the event is an intersection pointevent where s and s′ intersect at p:

1. Exchange s and s′ in T

2. If s′ and its new left neighbor inT intersect below the sweepline, then insert thisintersection point in Q

3. If s and its new right neighbor inT intersect below the sweepline, then insert thisintersection point in Q

4. . . .

p

s s′

Page 44: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

44/69Event handling

If the event is an intersection pointevent where s and s′ intersect at p:

1. Exchange s and s′ in T

2. If s′ and its new left neighbor inT intersect below the sweepline, then insert thisintersection point in Q

3. If s and its new right neighbor inT intersect below the sweepline, then insert thisintersection point in Q

4. Report the intersection point

p

s s′

Page 45: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

45/69Event handling

p

s

s′

Can it be that newhorizontal neighborsalready intersected abovethe sweep line?

Can it be that we insert anewly detected intersectionpoint event, but it alreadyoccurs in Q?

Insert events only once!

Page 46: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

45/69Event handling

p

s

s′

Can it be that newhorizontal neighborsalready intersected abovethe sweep line?

Can it be that we insert anewly detected intersectionpoint event, but it alreadyoccurs in Q?

Insert events only once!

Page 47: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

46/69Efficiency

How much time to handle an event?

At most one search in T and/or one insertion, deletion, orswap

At most twice finding a neighbor in T

At most one deletion from and two insertions in Q

Since T and Q are balanced binary search trees, handling anevent takes only O(logn) time

Page 48: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

47/69Efficiency

How many events?

I 2n for the upper and lower endpointsI k for the intersection points, if there are k of them

In total: O(n+ k) events

Page 49: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

48/69Efficiency

Initialization takes O(n logn) time (to put all upper and lowerendpoint events in Q)

Each of the O(n+ k) events takes O(logn) time

The algorithm takes O(n logn+ k logn) time

If k = O(n), then this is O(n logn)

Note that if k is really large, the brute force O(n2) timealgorithm is more efficient

Page 50: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

49/69Efficiency

Question: How much storage does the algorithm take?

Page 51: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

50/69Efficiency

Question: Given that the event list is a binary tree that maystore O(k) = O(n2) events, is the efficiency in jeopardy?

Page 52: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

51/69Efficiency

Solution:Only store intersection points of currently adjacent segments.

Page 53: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

52/69Degenerate cases

How do we deal with degenerate cases?

For two different events with the same y-coordinate, we treatthem from left to right⇒ the “upper” endpoint of ahorizontal line segment is its left endpoint

Page 54: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

53/69Degenerate cases

How about multiply coinciding event points?

p

Let U(p) and L(p) be the line segments that have p as upperand lower endpoint, and C(p) the ones that contain p

Question: How do we handle this multi-event?

Page 55: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

54/69Plane Sweep – Conclusion

For every sweep algorithm:

I Define the statusI Choose the status structure and the event listI Figure out how events must be handled (with sketches!)I To analyze, determine the number of events and how

much time they take

Then deal with degeneracies

Page 56: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

55/69Map overlay

To solve map overlay questions, weneed (at the least) intersectionpoints from two sets of linesegments.

Page 57: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

56/69Map overlay

To solve map overlayquestions, we also need to beable to represent subdivisions

clayclay sand

sandloess

rockrock

sand

sand

loess

clay

rock rock

clay

Page 58: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

57/69Subdivisions

A planar subdivision is a structure induced by a set of linesegments in the plane that can only intersect at commonendpoints. It consists of vertices, edges, and faces

face

vertex

edge

Page 59: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

58/69Subdivisions

Vertices are the endpoints of the linesegments

Edges are the interiors of the linesegments

Faces are the interiors of connectedtwo-dimensional regions that do notcontain any point of any line segment

Objects of the same dimensionality areadjacent or not; objects of differentdimensionality are incident or not adjacent

incident

Page 60: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

59/69Subdivisions

Exactly one face is unbounded, theouter face

Every other face is bounded and hasan outer boundary consisting ofvertices and edges

Any face has zero or more innerboundaries

Page 61: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

60/69Representing subdivisions

A subdivision representation has avertex-object class, an edge-objectclass, and a face-object class

It is a pointer structure whereobjects can reach incident (oradjacent) objects easily

Page 62: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

61/69Representing subdivisions

Use the edge as the central object

For any edge, exactly two verticesare incident, up to two faces areincident, and zero or more otheredges are adjacent

f1f2

v1

v2

Page 63: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

62/69Representing subdivisions

Use the edge as the central object,and give it a direction

Now we can speak of Origin,Destination, Left Face, and RightFace

fleft

vorigin

fright

vdestination

Page 64: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

63/69Representing subdivisions

Four edges are ofspecial interest fleft

fright

for fright

for frightfor fleft

for fleft

next edgenext edge

previous edgeprevious edge

Page 65: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

64/69Representing subdivisions

It would be nice if we could traversea boundary cycle by continuouslyfollowing the next edge for fleft orfright

. . . but, no consistent edgeorientation needs to exist

Page 66: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

65/69Representing subdivisions

We apply a trick/hack/impossibility:split every edge length-wise(!) intotwo half-edges

Every half-edge:

I has exactly one half-edge as itsTwin

I is directed opposite to its TwinI is incident to only one face (left)

~e Twin(~e)

Next(~e)

Prev(~e)

Page 67: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

66/69The doubly-connected edge list

The doubly-connected edgelist is a subdivisionrepresentation structure withan object for every vertex,every half-edge, and everyface

A vertex object stores:

I CoordinatesI IncidentEdge (some

half-edge leaving it)

A half-edge object stores:

I Origin (vertex)I Twin (half-edge)I IncidentFace (face)I Next (half-edge in cycle of

the incident face)I Prev (half-edge in cycle of

the incident face)

Page 68: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

67/69The doubly-connected edge list

A face object stores:

I OuterComponent(half-edge of outer cycle)

I InnerComponents (list ofhalf-edges for the innercycles bounding the face)

f

Page 69: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

68/69The doubly-connected edge list

A vertex object stores:

I CoordinatesI IncidentEdgeI Any attributes, mark bits

A face object stores:

I OuterComponent(half-edge of outer cycle)

I InnerComponents(half-edges for the innercycles)

I Any attributes, mark bits

A half-edge object stores:

I Origin (vertex)I Twin (half-edge)I IncidentFace (face)I Next (half-edge in cycle of

the incident face)I Prev (half-edge in cycle of

the incident face)I Any attributes, mark bits

Page 70: Lecture: Line segment intersection and subdivisionsand sis the line segment that ends at p: 1.Search with pin T, and delete s 2.Let s l and s r be the left and right neighbors of sin

69/69Map overlay problem

The map overlay problem for twosubdivisions S1 and S2 is to computea subdivision S that is the overlay ofS1 and S2

All edges of S are (parts of) edgesfrom S1 and S2. All vertices of S arealso in S1 or S2, or intersections ofedges from S1 and S2

The line-segment intersectionalgorithm can be extended to thisproblem using doubly-connectededge lists. [Chapter 2.3]