SLIDE 1 Extraction of data/primitives inside a region of interest “window” => Discard (parts of ) primitives outside window. Point Clipping: Remove points outside window.
- A point is either entirely inside the window or not
(xL, yB) (xR, yT)
P Q
xL <= x <= xR yB <= y <= yT Q is inside P is outside
SLIDE 2 Line Clipping: Remove portion of line segment
- utside window
- Can we use point clipping for the end points?
Point clipping works
1 2
SLIDE 3 Line Clipping: Remove portion of line segment
- utside window
- How about these lines?
Point clipping does not work
3 4 5
SLIDE 4
Cohen and Sutherland
SLIDE 5
Cohen and Sutherland
1xxx xxx1 x1xx xx1x 0000
4 bit code to indicate the zone of end points of line with respect to window
SLIDE 6
Cohen and Sutherland
0000
4 bit code to indicate the zone of end points of line with respect to window
1000 0001 0100 0010 1001 1010 0101 0110
SLIDE 7 Cohen and Sutherland
Trivially accept case
- line is totally visible
- if both ends of the line have outcode as 0000
Trivially accept
SLIDE 8 Cohen and Sutherland
Trivially reject case
- line is totally invisible
- logical AND of the two end points outcodes
Trivially reject
SLIDE 9 Cohen and Sutherland
If not trivially reject and accept case
- line is potentially visible
Potentially visible
SLIDE 10 Cohen and Sutherland
If potentially visible
- subdivide into segments and apply trivial acceptance
and rejection test
- segments by intersection with window edges
- edges in any order but consistent
(e.g., top-bottom, right-left)
D A B A B
Result
SLIDE 11 Cohen and Sutherland
- simple, still popular
- limited to rectangular region
- extension to 3D clipping using 3D orthographic
view volume is straightforward
SLIDE 12
SLIDE 13 Cyrus Beck Line Clipping
(Liang and Barsky)
Parametric line (input line AB):
) 1 , ( ; ) ( ) ( ∈ − + = t t A B A t L
A B
SLIDE 14 Cyrus Beck Line Clipping
(Liang and Barsky) P n
Implicit line (window edge): Tells us on which side of the line the point Q is.
n P Q Q l ). ( ) ( − =
SLIDE 15 Cyrus Beck Line Clipping
(Liang and Barsky) P n
n P Q Q l ). ( ) ( − =
Evaluate If > 0 inside halfspace of line (plane) If < 0 outside halfspace of line (plane) If = 0 on the line Should give indications for trivial accept and reject cases.
Inside Outside
SLIDE 16 Cyrus Beck Line Clipping
(Liang and Barsky) P n
n P Q Q l ). ( ) ( − =
Inside Outside
) ( ) ( A B t A t L − + =
Window edge Line segment
) ( AND ) ( < < B l A l ) ( AND ) ( > > B l A l
Trivial Reject Trivial Accept
SLIDE 17
Cyrus Beck Line Clipping
(Liang and Barsky) P n
SLIDE 18
Cyrus Beck Line Clipping
(Liang and Barsky) P n A B
t A B A t L ) ( ) ( − + = t for solve ; )) ( ( = t L l n P Q Q l ). ( ) ( − =
). ( ). ( ). ) ( ( ). ) ( ( = − + − = − − + = − n A B t n P A n P A B t A n P t L
SLIDE 19
Cyrus Beck Line Clipping
(Liang and Barsky) P n A B
n P B n P A n P A t n A B n P A t ). ( ). ( ). ( ). ( ). ( − − − − = − − =
SLIDE 20
B
n
Which ‘t’ to select ? (t=0) (t=1)
Cyrus Beck Line Clipping
(Liang and Barsky) A
SLIDE 21
A B
n
(t=0) (t=1)
Cyrus Beck Line Clipping
(Liang and Barsky)
n A B D n A B n P A t ). ( ). ( ). ( − = − − =
D > 0 label t as tE Entering
SLIDE 22
A B
n
(t=0) (t=1)
Cyrus Beck Line Clipping
(Liang and Barsky)
n A B D n A B n P A t ). ( ). ( ). ( − = − − =
D < 0 label t as tL Leaving
SLIDE 23
A B
n
(t=0) (t=1)
Cyrus Beck Line Clipping
(Liang and Barsky) t of interest: largest tE smallest tL
max E
t
min L
t
SLIDE 24
If
Cyrus Beck Line Clipping
(Liang and Barsky)
min max L E
t t >
Reject
SLIDE 25
Arbitrary Convex Window
P1
V1
Cyrus Beck Line Clipping
(Liang and Barsky)
V2 V3 V4 V5 V6 V7 V8
P2 E1 E2 E3 E4 E5 E6 E7 E8
SLIDE 26
Arbitrary Convex Window
P1
V1
Cyrus Beck Line Clipping
(Liang and Barsky)
V2 V3 V4 V5 V6 V7 V8
P2 E1 E2 E3 E4 E5 E6 E7 E8
Polygon is convex if for all adjacent edges the sign of cross product is same.
positive xE E positive xE E : :
3 2 2 1
. . .
SLIDE 27
Arbitrary Window
Cyrus Beck Line Clipping
(Liang and Barsky) Polygon is non-convex
negative xE E positive xE E positive xE E : : :
4 3 3 2 2 1
. . .
V1 V2 V3 V4 V5 V6 E1 E2 E3 E4
SLIDE 28
Arbitrary Window
Cyrus Beck Line Clipping
(Liang and Barsky)
V1 V2 V3 V4 V5 V6 E1 E2 E3 E4
Make the polygon convex by adding the edge V3V5 Clip against the convex polygon => P3P4
P1 P2 P3 P4
SLIDE 29
Arbitrary Window
Cyrus Beck Line Clipping
(Liang and Barsky)
V3 V4 V5
Clip against the triangle => P5P4 Subtract P5P4 from P3P4 => P3P5
P3 P4 P5