Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations.

Presentation on theme: "Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations."— Presentation transcript:

Many slides are borrowed from Foley & Van Dam

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

? ?

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

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

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

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

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.

Simultaneous Equations

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

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

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

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

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 1 0 11 00 01 10 Same encoding Different encoding

1 2 3 4

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

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

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

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

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

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)

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

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!

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!

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?

Download ppt "Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations."

Similar presentations