Check if the line segment is trivial acceptreject 2

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: below bottom, y < ymin Third bit : to right of right edge, x > xmax Fourth bit : to left of left edge, x < xmin Cohen-Sutherland algorithm While (true) { 1. Check if the line segment is trivial accept/reject 2. Otherwise clip the edge and shorten } Recap of AND/OR operators 0 OR 0 = 0 0 OR 1 = 1 1 OR 1 = 1 (if either is true, true) 0 AND 0 = 0 1 AND 0 = 0 1 AND 1 = 1 (if both are true, true) What is a trivial accept? • All line vertices lie inside box → accept. – Apply an ‘OR’ operation to the outcodes of two endpoints Cohen-Sutherland algorithm While (true) { 1. Check if the line segment is trivial accept/reject 2. Otherwise clip the edge and shorten } What is a trivial reject? All line vertices lie outside and on same side → reject. Apply an ‘AND’ operation to the two endpoints If not ‘0000’, then reject Can be checked by the ‘and’ operation of the two end points Cohen-Sutherland 2D outcodes 1001 1010 1000 1000 0001 0000 0001 0010 0000 0000 0101 0100 0110 Logical AND between codes for 2 endpoints, Reject line if non-zero – trivial rejection. What about this one? 1001 1000 1010 0000 0010 0100 0110 0001 0101 Logical AND between codes for 2 endpoints, Reject line if non-zero – trivial rejection. Cohen-Sutherland algorithm While (true) { 1. Check if the line segment is trivial accept/reject 2. Otherwise clip the edge and shorten } Line Intersection. • Clip the line by edges of the rectangle...
View Full Document

This document was uploaded on 03/26/2014.

Ask a homework question - tutors are online