Professional Documents
Culture Documents
Cohen-Sutherland Example
Remember, outcodes are: above | below | right | left 1000 B
Cohen-Sutherland Example
1000 B
1. A&B = 0 0001 0000 A 0100 0010 So we need to do something further. Neither point has zero outcode, so we choose either, well start with A. We find first nonzero bit and split at implied edge (bottom).
Cohen-Sutherland Example
1000 B
1. A&B = 0 0001 C We can throw away A-C, new line is C-B. A 0100 0000 0010 So we need to do something further. Neither point has zero outcode, so we choose either, well start with A. We find first nonzero bit and split at implied edge (bottom).
Cohen-Sutherland Example
1000 B We now have this situation: 0001 C 0000 0010 C = 0001 B = 1010 2. C&B = 0 Both are nonzero so well pick C arbitrarily.
0100
Cohen-Sutherland Example
1000 B First non-zero bit in C implies left edge is crossed, split at intersection to get D.
0001 C D 0000
0010
0100
Cohen-Sutherland Example
1000 B First non-zero bit in C implies left edge is crossed, split at intersection to get D.
0001 D 0000
0010
0100
Cohen-Sutherland Example
1000 B Finally, we have a point with a zero outcode: D = 0000 B = 1010 0001 D 0000 0010 But B is nonzero. We dont need to perform an AND we definitely have more work to do. So we turn our attention to point B
0100
Cohen-Sutherland Example
1000 B E First non-zero bit of B implies crossing of upper boundary. So we split at intersection with upper boundary to get E.
0001 D 0000
0010
0100
Cohen-Sutherland Example
1000 We can throw away E-B, so new line is D-E. E First non-zero bit of B implies crossing of upper boundary. So we split at intersection with upper boundary to get E.
0001 D 0000
0010
0100
Cohen-Sutherland Example
1000 E We are left with: D = 0000 0001 D 0000 0010 E = 0010 Again, we have one non-zero outcode. Dont need to perform AND, but still cant do a trivial accept.
0100
Cohen-Sutherland Example
1000 E F 0001 D 0000 0010 First non-zero bit of E implies right edge crossing. Compute intersection, giving F.
0100
Cohen-Sutherland Example
1000
Throw away E-F. Both outcodes equal zero, so we trivially accept the line.
0100
y = ymax
1. 2D or 3D method for clipping line segments. 2. Assigns outcodes to start and end points, can decide what to do based on whether outcodes and their logical AND are non-zero. 3. Sometimes performs redundant clipping. Fast when there are lots of trivial accepts/rejects (i.e. lots of line segments totally outside or totally inside). Parametric clipping algorithms (Ling-Barsky) Try to avoid explicit intersection calculations, can order parameter values and make inferences works in 3D Sutherland-Hodgman algorithm Clipping polygons, divide and conquer algorith. For each edge of view volume, traverse list of vertices