Circle & curve clipping algorithm


Published on

Explain Circle Clipping

Published in: Education
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Circle & curve clipping algorithm

  1. 1. Circle & Curve Clipping Algorithm<br />Presented By : <br /> Mohamed El-Serngawy<br />
  2. 2. Outline<br />Fast Circle Clipping Algorithm<br />Clipping Circle By Accept/Reject Test<br />
  3. 3. Fast Circle Clipping Algorithm<br />Introduction:<br />
  4. 4. Fast Circle Clipping Algorithm<br />Algorithm<br />
  5. 5. Fast Circle Clipping Algorithm<br />Algorithm<br />
  6. 6. Fast Circle Clipping Algorithm<br />Algorithm<br />
  7. 7. Fast Circle Clipping Algorithm<br />Algorithm<br />
  8. 8. Fast Circle Clipping Algorithm<br />Algorithm<br />
  9. 9. Clipping Circle By Accept/Reject Test<br />1-Scan Conversion of Circles <br />2-Write Points(x,y)<br />3-Clipping Circles<br />
  10. 10. Midpoint Circle Algorithm<br />Choose E as the next pixel if M lies inside the circle, and SE otherwise.<br />d =<br />d<0: Select E<br />dnew = d + (2xp+3)<br />d>0: Select SE<br />dnew = d + (2xp–2yp+5)<br />E<br />M<br />SE<br />xp<br />xp+1<br />
  11. 11. Midpoint Circle Algorithm<br />Start with P (x = 0, y = r). Compute d for the first midpoint at (1, r - ½): d = F(1, r - ½) = 5/4 - r<br />While (x < y) {<br /> If (d <= 0) // E is chosen<br />d = d + 2 * x + 3 <br /> Else // SE is chosen<br />y = y – 1<br />d = d + 2 * x – 2 * y + 5<br /> x = x+1; WritePixel (x, y)<br />}<br />
  12. 12. Write Points(x,y)<br />Writes pixels to the seven other octants<br />
  13. 13. Clipping Circles<br />Accept/Reject test<br /> – Does bounding box of<br /> the circle intersect with clipping box?<br />If yes, condition pixel<br /> write on clipping box inside/outside test<br />Also we can test Circle points by Point <br />Clipping .<br />-the point P=(x, y) is display in clipping <br />Boundry if <br />xmin< x <xmaxandymin<y<ymax<br />
  14. 14. Curve Clipping<br />Areas with curved boundaries can be clipped with methods similar to those discussed<br />in the previous .sections. Curve-clipping procedures will involve nonlinear<br />equations, however, and this requires more processing than for objects with<br />linear boundaries.<br />The bounding rectangle for a circle or other curved object can be used first<br />to test for overlap with a rectangular clip window. If the bounding rectangle for<br />the object is completely inside the window, we save the object. If the rectangle is<br />determined to be completely outside the window, we discard the object. In either<br />case, there is no further computation necessary. But if the bounding rectangle test<br />fails, we can look for other computation-saving approaches. For a circle, we can<br />use the coordinate extents of individual quadrants and then octants for preliminary<br />testing before calculating curve-window intersections. For an ellipse, we can<br />test the coordinate extents of individual quadrants. Figure blew illustrates circle<br />clipping against a rectangular window.<br />
  15. 15. Curve Clipping<br />Similar procedures can be applied when clipping <br />a curved object against a general polygon clip region. <br />On the first pass, we can clip the bounding rectangle<br />of the object against the bounding rectangle of the clip <br />region. <br />If the two regions overlap, we will need to solve the <br />simultaneous line-curve equations to obtain<br />the clipping intersection points.<br />