Outcode


Region and Outcode

Each region of the nine regions is assigned a 4-bit code, the nine regions and their outcodes are shown below:

Picture of OUTCODE>

        <UL>
        <LI> Bit 1 : sign bit of (Ymax-Y), point is above window</LI>
        <LI> Bit 2 : sign bit of (Y-Ymin),  point is below window</LI>
        <LI> Bit 3 : sign bit of (Xmax-X), point is to right of window</LI>
        <LI> Bit 4 : sign bit of (X-Xmin),  point is to left of window</LI>
        </UL>

      <H2>Usage of Outcode</H2>

        <UL>
        <LI> A line can be trivially accepted if both endpoints
             have an outcode of 0000.</LI>
        <LI> A line can be trivially rejected if any corresponding
             bits in the two outcodes are both equal to 1.
             (This means that both endpoints are to the right, to
             the left , above, or below the window).<BR>
             If the logical AND of the codes of the endpoints is not
             zero, the line can be trivially rejected.</LI>
        </UL>

      <H2>Example</H2>

        <P>The following is an example of how the C-S algorithm
           works using the outcode.</P>

        <IMG ALIGN=bottom SRC=

Line AD:

  1. Test outcodes of A and D; can't accept or reject.
  2. Calculate Intersection point B, form new line segment AB and discard BD because it is above the window.
  3. Test outcodes of A and B; reject.

Line EH:

  1. Test outcodes of E and H; can't accept or reject.
  2. Calculate Intersection point G, form new line segment EG and discard GH because it is right to the window.
  3. Test outcodes of E and G; can't accept or reject.
  4. Calculate Intersection point F, form new line segment FG and discard EF because it is left to the window.
  5. Test outcodes of F and G; accept.

Go back to Cohen-Sutherland Algorithm


Contact:
Haowei Hsieh
hhsieh@cc.gatech.edu
http://www.cc.gatech.edu/gvu/people/Masters/Haowei.Hsieh.html
Last Change : Feb 19,1995