-->

Cohen-Sutherland Line Clipping Algorithm with C/C++

Cohen-Sutherland Line Clipping Algorithm with C/C++
    Theory
    In this method, every line endpoint is assigned a four digit binary code(region code) that identifies the location of the point relative to the boundary.
    b1 : left
    b2 : right
    b3 : below
    b4 : above
    The value 1 indicates its relative position. If a point is within clipping rectangle then region code is 0000. So ,
    If x – xwmin < 0 , b1 = 1
    If xwmax – x < 0 , b2 = 1
    If y – ywmin < 0 , b3 = 1
    If ywmin – y < 0 , b4 = 1
    If the region codes of both end points are 0000 then we accept
    the line. Any line that have one in the same bit position is rejected i.e If RA AND RB ≠ 0 ,line is completely outside .
    The lines which con not be identified as completely inside or outside a window by these tests are checked for intersection with the window boundary. Such lines may or may not cross into the window interior.
    Read more »
    fardi zayden
    @مرسلة بواسطة
    كاتب ومحرر اخبار اعمل في موقع دراسات تقنية .

    إرسال تعليق