15
Circle & Curve Clipping Algorithm Presented By : Mohamed El-Serngawy

Circle & curve clipping algorithm

Embed Size (px)

DESCRIPTION

Explain Circle Clipping

Citation preview

Page 1: Circle & curve clipping algorithm

Circle & Curve Clipping Algorithm

Presented By : Mohamed El-Serngawy

Page 2: Circle & curve clipping algorithm

OutlineFast Circle Clipping AlgorithmClipping Circle By Accept/Reject

Test

Page 3: Circle & curve clipping algorithm

Fast Circle Clipping Algorithm

Introduction:

Page 4: Circle & curve clipping algorithm

Fast Circle Clipping Algorithm

Algorithm

Page 5: Circle & curve clipping algorithm

Fast Circle Clipping Algorithm

Algorithm

Page 6: Circle & curve clipping algorithm

Fast Circle Clipping Algorithm

Algorithm

Page 7: Circle & curve clipping algorithm

Fast Circle Clipping AlgorithmAlgorithm

Page 8: Circle & curve clipping algorithm

Fast Circle Clipping AlgorithmAlgorithm

Page 9: Circle & curve clipping algorithm

Clipping Circle By Accept/Reject Test

1-Scan Conversion of Circles 2-Write Points(x,y)3-Clipping Circles

Page 10: Circle & curve clipping algorithm

Midpoint Circle Algorithm),( pp yxP E

SE

M

Choose E as the next pixel if M lies inside the circle, and SE otherwise.

d =d<0: Select E

dnew = d + (2xp+3)

d>0: Select SEdnew = d + (2xp–2yp+5)

22

2

2

1)1(

2

1,1 RyxyxF

xp xp+1

Page 11: Circle & curve clipping algorithm

Midpoint Circle Algorithm

Start with P (x = 0, y = r). Compute d for the first midpoint at (1, r - ½): d = F(1, r - ½) = 5/4 - r

While (x < y) {

If (d <= 0) // E is chosen d = d + 2 * x + 3

Else // SE is chosen y = y – 1 d = d + 2 * x – 2 * y + 5x = x+1; WritePixel (x, y)

}

Page 12: Circle & curve clipping algorithm

Write Points(x,y)Writes pixels to the seven other

octants

Page 13: Circle & curve clipping algorithm

Clipping Circles

Accept/Reject test

– Does bounding box of

the circle intersect with clipping box? If yes, condition pixel

write on clipping box inside/outside test

Also we can test Circle points by Point

Clipping .

-the point P=(x, y) is display in clipping

Boundry if xmin < x < xmax and ymin < y < ymax

Page 14: Circle & curve clipping algorithm

Curve ClippingAreas with curved boundaries can be clipped with methods similar to those

discussed

in the previous .sections. Curve-clipping procedures will involve nonlinear

equations, however, and this requires more processing than for objects with

linear boundaries.

The bounding rectangle for a circle or other curved object can be used first

to test for overlap with a rectangular clip window. If the bounding rectangle for

the object is completely inside the window, we save the object. If the rectangle is

determined to be completely outside the window, we discard the object. In either

case, there is no further computation necessary. But if the bounding rectangle test

fails, we can look for other computation-saving approaches. For a circle, we can

use the coordinate extents of individual quadrants and then octants for preliminary

testing before calculating curve-window intersections. For an ellipse, we can

test the coordinate extents of individual quadrants. Figure blew illustrates circle

clipping against a rectangular window.

Page 15: Circle & curve clipping algorithm

Curve ClippingSimilar procedures can be applied when clipping

a curved object against a general polygon clip region.

On the first pass, we can clip the bounding rectangle

of the object against the bounding rectangle of the clip

region.

If the two regions overlap, we will need to solve the

simultaneous line-curve equations to obtain

the clipping intersection points.