Thursday, November 19, 2015

Cohen-Sutherland Line clipping algorithm.



Cohen-Sutherland Line Clipping :
1.      Region Code Creation
–Region Code
•Bit 1: left
•Bit 2: right
•Bit 3: below
•Bit 4: above
–Calculate differences between endpoint coordinates and clipping boundaries
–Use the resultant sign bit of each difference calculation to set the corresponding value in the region code 
1.      Outside Line Removal Test
–A method that can be used to test lines total clipping is to perform the logical and operation with both region codes
–Not 0000
2.      Completely outside the clipping region!!
3.      Lines that cannot be identified as completely inside or outside a clip window by this test.
4.      Calculate Intersection Point
– Using the slope-intercept form
– Vertical Boundary, y = y1 + m ( x – x1)
– Horizontal Boundary

No comments:

Post a Comment