Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren...

53
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001

Transcript of Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren...

Page 1: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Institut für Kartographie und GeoinformationProf. Dr. Lutz Plümer

Scan-Line-Verfahren

Geoinformation II(6. Semester)

Vorlesung 1

SS 2001

Page 2: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

2 2

Übersicht I

• Übersicht über das Semester• Organisation

• Overlay• n-Segment-Schnitt

• Zur Erinnerung („Diskrete Mathematik“)• Groß-Oh-Notation

• Wachstum

• Hinreichende Bedingung für Schnittfreiheit• Scan-Line-Verfahren

• Idee• Scan-Line-Verfahren

• Gegenbeispiel

• Nachbarschaft

Page 3: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

3 3

Übersicht II

• Verfeinerung des Algorithmus

• Ordnungsrelation „x <‘‘

• Ordnung der Segmente durch die Scan-Line

• Verwaltung der aktiven Elemente

• Wann wird der Schnittpunkt S1 erkannt?

• Vereinfachende Annahmen

• Algorithmus Scan-Line

• Algorithmus II

• Prüfung auf Schnittfreiheit

• Segmentschnitt I

• Segmentschnitt II

• Einfacher Segmentschnitt I

• Einfacher Segmentschnitt II

Page 4: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

4 4

Übersicht über das Semester

• was ist „GIS 2“?– Funktionen von GIS

• Algorithmen in GIS

• effiziente Berechnung

– Speicherung räumlicher Objekte in GIS

• effiziente Suche

• GIS 1 = Modelle für GIS Welt Modell

• GIS 2 = Modell Rechner• 2 große Algorithmen

– Overlay von Netzen und Flächen (Segmentschnitt)

– räumliche Nachbarschaft

• Voronoi-Diagramm,

• Delaunay- Triangulation

Page 5: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

5 5

Motivation: Overlay von Flächen und Landkarten

• von Netzen:– Fluß und Straßennetz: Brücken– Straßen und Eisenbahnnetz: Brücken, Tunnel– Problem: Schnitt von n geraden Linien-Segmenten

• von Landkarten (polygonalen Strukturen)– PLZ und Verkaufsbezirke– Gemeinden und Geologie– Problem: Segmentschnitt + Polygonkonstruktion– heute nur: Schnitt von n Segmenten

Page 6: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

6 6

n-Segment-Schnitt

• einfaches Vorgehen:– paarweiser Vergleich:

s S: s‘ S - {s}überprüfe s und s‘ auf Schnittfreiheit und bestimme ggf. den Schnitt von s und s‘

• Laufzeit: O(n2)für die Praxis viel zu langsam

• Ziel: O(n * log n)• harter und langer Kampf!• erste Idee: betrachte horizontale Projektionen

Page 7: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

7 7

Zur Erinnerung („Diskrete Mathematik“)

Groß-Oh-Notation

Definition:

},n> n alle für f(n)cg(n) mit

0c|NN :{g O(f)

0

00

wobei

...}, 2, 1, {0,N 0 existiert" es "

Page 8: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

8 8

Groß-Oh-Notation

Beispiele:

)O(n n 2 )O(n n5000 2

)O(n n5000n 22 )O(n nn 323

O(log n)

O(n log n)

O(n3)

O(n)

... O(exp n)

O(1)

O(n2)

Inklusion:

Page 9: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

9 9

Wachstum

0

10

20

30

40

50

0 2 4 6 8 10 12 14 16 18 20

n log n

Page 10: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

10 10

Hinreichende Bedingung für Schnittfreiheit

• notwendig für Schnitt: Überlappung der horizontalen Projektionen

• Reduktion einer 2-dimensionalen auf eine 1-dimensionale Fragestellung

Page 11: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

11 11

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 12: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

12 12

Idee:

• horizontale Scan-Line über die Ebene schieben– aktive Elemente: Schnitt mit der Scan-Line– nur aktive Elemente können horizontale Überschneidungen

haben– überprüfe aktive Elemente auf Schnittfreiheit

• Problem: wo sind die Haltepunkte der Scan-Line– Anfangspunkt eines Segments

– Endpunkt eines Segments

– geordnete Menge der x-Koordinaten

Page 13: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

13 13

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 14: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

14 14

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 15: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

15 15

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 16: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

16 16

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 17: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

17 17

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 18: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

18 18

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 19: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

19 19

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 20: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

20 20

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 21: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

21 21

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 22: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

22 22

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 23: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

23 23

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 24: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

24 24

Scan-Line-Verfahren

A

BF

C

D

ES1

S3

S2

S4

Page 25: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

25 25

Gegenbeispiel

zu viele Elemente gleichzeitig aktiv O(n2)

Page 26: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

26 26

Nachbarschaft

-Umgebung

A

B

Page 27: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

27 27

Verfeinerung des Algorithmus

• nur benachbarte Segmente betrachten• wie erkennt man sehr schnell, ob zwei Segmente benachbart

sind?• Nutzung der Scan-Line

– Betrachte die Schnittpunkte der aktiven Segmente mit der Scan-Line

– Nachbarschaft ergibt sich aus der Lage der Schnittpunkte

Page 28: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

28 28

Ordnungsrelation „x <‘‘

x x‘

B

A

C

Ax < B

Ax < C

Cx‘ < A

Cx < B

Ax‘ < B

Cx‘ < B

Page 29: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

29 29

Ordnung der Segmente durch die Scan-Line

x< ist eine dynamische (!) Ordnung ...– die nur auf der Menge der aktiven Elemente definiert ist– die Ordnung x< zwischen zwei Elementen wird an ihren

Schnittpunkten umgedreht• aus

a x< b wird am Schnittpunkt s von a und b

b x< a– liefert eine vollständige eindimensionale Ordnung der

aktiven Segmente ...– ... für jeden Haltepunkt der Scan-Line !

Page 30: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

30 30

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

Page 31: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

31 31

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

A

Page 32: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

32 32

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

AE

Page 33: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

33 33

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

EA

Page 34: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

34 34

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

DA

E

Page 35: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

35 35

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

CA

DE

Page 36: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

36 36

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

DC

E

Page 37: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

37 37

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

EC

D

Page 38: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

38 38

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

F

CB

ED

Page 39: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

39 39

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

CF

ED

Page 40: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

40 40

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

B

CF

E

Page 41: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

41 41

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

C

EF

Page 42: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

42 42

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

C

FE

Page 43: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

43 43

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

C

Page 44: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

44 44

Verwaltung der aktiven Elemente

A

BF

C

D

ES1

S3

S2

S4

Page 45: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

45 45

Wann wird der Schnittpunkt S1 erkannt?

A

S1

Übung: Wird ein Schnittpunkt stets genau einmal erkannt?

C

D

E

B

Page 46: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

46 46

Vereinfachende Annahmen

Annahme• 2 Segmente schneiden sich

höchstens in einem Punkt

• in keinem Punkt schneiden sich mehr als 3 Segmente

• die x-Koordinaten aller Segmente sind paarweise verschieden

• kein Segment ist vertikal

Gegenbeispiel

Page 47: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

47 47

Algorithmus Scan-Line

Input:

S: eine Menge von Segmenten

Output:

die Schnittpunkte der Elemente von S

Sei

T = Endpunkte der Segmente von S nach x-Koordinaten sortiert (Haltepunkte)

L = // aktive Segmente von S

while T do

bestimme und entferne den nächsten Punkt pT

x ist x-Koordinate von p

case: p ist linker Endpunkt von sfuege_ein(s,x,L)sl = vorgaenger(s,x,L)sr = nachfolger(s,x,L)

schnitt(sl,s,T);

schnitt(s,sr,T);

p ist rechter Endpunkt von s

sl = vorgaenger(s,x,L)sr = nachfolger(s,x,L)

entferne(s,x,L)

schnitt(sl,sr,T)

p ist Schnittpunkt von s und t

vertausche(s,t,L,x) // t < ssl = vorgaenger(t,x,L)sr = nachfolger(s,x,L)

schnitt(sl,t,T)

schnitt(s,sr,T)

Page 48: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

48 48

Algorithmus II

fuege_ein(s,x,L): fügt das Segment s in die Menge L ein entsprechend der Ordnung an der Stelle x

entferne(s,x,L): entfernt das Segment s aus die Menge L an der Stelle x

nachfolger(s,x,L): liefert den Nachfolger von s in L an der Stelle x, falls vorhanden

vorgaenger(s,x,L) liefert den Vorgänger von s in L an der Stelle x, falls vorhanden

schnitt(s,t,T) prüft s und t auf Schnitt. Berechnet ggf. den Schnittpunkt p und fügt ihn als neuen Haltepunkt in T ein.

offene Probleme:

eine geeignete Datenstruktur für T

eine geeignete Datenstruktur für L

Prüfung auf Schnitt, Berechnung des Schnittpunkts

Page 49: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

49 49

Prüfung auf Schnittfreiheit

• 1. Idee– Berechnung der Geradengleichungen g und g‘ der

Segmente s und s‘– Schnittpunkt p von g und g‘– prüfe ob p in s und s‘

• Problem– vertikale Segmente– Vermeidung unangenehmer Sonderfälle

Page 50: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

50 50

Segmentschnitt I

g1

g2

c)

g2g1

b)

g1

g2

a)

Page 51: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

51 51

Segmentschnitt II

• Reduktion auf das Problem

• P1, P2 liegen auf der gleichen / verschiedenen Seiten der durch g induzierten Geraden

• Homogene Koordinaten:P1=(x1,y1,w1)P2=(x2,y2,w2)P=(x,y,w)

D > 0

D < 0

D = 0P

P2

P1s

g auf P liegt ist, 0D wenn

g von rechts P liegt ist, 0D wenn

g von links P liegt ist, 0D wenn

www

yyy

xxx

D)P,PD(P,

21

21

21

21

Page 52: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

52 52

Einfacher Segmentschnitt I

S1 = det ( P1,P3,P4) Def.: Vor.: Alle Determinanten sind 0:S2 = det ( P3,P1,P2) g und g` schneiden sich genau dann, wenn S1, S2

S3 = det ( P2,P3,P4) sowie S3, S4 jeweils verschiedene Vorzeichen S4 = det ( P4,P1,P2) haben.

P2

P1

P3 P4

P2

P3

P4

P1g

g`

P2

P1

P3

P4

Page 53: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Scan-Line-Verfahren Geoinformation II (6. Semester) Vorlesung 1 SS 2001.

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 1

53 53

Einfacher Segmentschnitt II

Wenn alle Determinanten gleich Null sind, dann folgt daraus, daß alle vier Punkte kollinear sind.

- eine Determinante ist Null:

=> Algorithmus: Einsparen von Multiplikationen