Download presentation

Presentation is loading. Please wait.

Published byIrea Reap Modified over 2 years ago

1
Many slides are borrowed from Foley & Van Dam

2
Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations – Cohen-Sutherland Line Clipping Algorithm – Cyrus-Beck / Liang-Barsky Line Clipping Algorithm Sutherland-Hodgman Polygon Clipping

3

4

5

6

7
? ?

8

9
Line Clipping Endpoints Configuration – Both inside: ? – One in, one out: ? – Both outside: ?

10
Line Clipping Endpoints Configuration – Both inside: No need for clipping – One in, one out: ? – Both outside: ?

11
Line Clipping Endpoints Configuration – Both inside: No need for clipping – One in, one out: ? – Both outside: ?

12
Line Clipping Endpoints Configuration – Both inside: No need for clipping – One in, one out: 1 intersection point – Both outside: ?

13
Line Clipping Endpoints Configuration – Both inside: No need for clipping – One in, one out: 1 intersection point – Both outside: 2/0 intersection points Is more than 2 intersection points possible? No, intersection of 2 convexes is still a convex.

14
Simultaneous Equations

15

16
Any better algorithm? P1P2Observation Out ? Exterior half plane Possible interior half plane

17
Any better algorithm? P1P2Observation Out No intersection with the line(reject) In ? Exterior half plane Possible interior half plane

18
Any better algorithm? P1P2Observation Out No intersection with the line(reject) In No intersection with the line Out/InIn/Out? Exterior half plane Possible interior half plane

19
Any better algorithm? P1P2Observation Out No intersection with the line(reject) In No intersection with the line Out/InIn/OutOne intersection point with the line Exterior half plane Possible interior half plane

20
Any better algorithm? P1P2Observation Out No intersection with the line(reject) In No intersection with the line OOne intersection point with the line Exterior half plane Possible interior half plane Same encoding Different encoding

21

22

23
Cohen-Sutherland for Line Clipping For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11: trivially reject; //outside of the window return; case 00: continue; //no intersection point case 10 or 01: compute intersection point; refresh one endpoint by the intersection point; continue 0 0 1

24
Cohen-Sutherland for Line Clipping For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11: trivially reject; //outside of the window return; case 00: continue; //no intersection point case 10 or 01: compute intersection point; refresh one endpoint by the intersection point; 2 Replace endpoint with the intersection Pt 0 1

25
Cohen-Sutherland for Line Clipping For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11: trivially reject; //outside of the window return; case 00: continue; //no intersection point case 10 or 01: compute intersection point; refresh one endpoint by the intersection point; 3 continue 0 0

26
Cohen-Sutherland for Line Clipping For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11: trivially reject; //outside of the window return; case 00: continue; //no intersection point case 10 or 01: compute intersection point; refresh one endpoint by the intersection point; 4 Replace endpoint with the intersection pt 1 0

27
Any even better algorithm? A trivial quiz…… There are multiple layers of doors for entering a room, and multiple layers of doors for exiting a room. Assume we dont know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left. DoorEntering TimeLeaving Time A0.1 B0.5 C0.6 D0.8

28
Any even better algorithm? A trivial quiz…… There are multiple layers of doors for entering a room, and multiple layers of doors for exiting a room. Assume we dont know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left. DoorEntering TimeLeaving Time A0.1 B0.5 C0.6 D0.8 Time range of the person in the room Max(0.1,0.5) – Min(0.6,0.8)

29
Any even better algorithm? A trivial quiz…… There are multiple layers of doors for entering a room, and multiple layers of doors for exiting a room. Assume we dont know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left. DoorEntering TimeLeaving Time A0.1 B0.6 C0.3 D0.8

30
Any even better algorithm? A trivial quiz…… There are multiple layers of doors for entering a room, and multiple layers of doors for exiting a room. Assume we dont know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left DoorEntering TimeLeaving Time A0.1 B0.6 C0.3 D0.8 Time range of the person in the room Max(0.1,0.6) – Min(0.3,0.8) Never in the room!

31
Cyrus-Beck/Liang-Barsky Line Clipping P1 P0 E (t = 0.03) L (t = 0.85) L(t = 0.8) E (t = -0.03) Entering Time: t = 0.13 Leaving Time: t = 0.8 Ignore ts 1 Max(Entering) ~Min(Leaving) Max(E) > Min(L) ? Totally outside!

32
Cyrus-Beck/Liang-Barsky Line Clipping Questions we need to answer: – How to decide entering or leaving – Knowing entering or leaving, how to compute t?

33

34

35

36

37

38

39

40

41

42

43

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google