70 likes | 87 Views
Circle Scan Conversion. We assume the following – The circle centered at (0,0) – We draw 1/8 of the circle, Then use 8-way symmetry. Not 8-way Symmetry. Circle Scan Conversion. We assume (xp, yp) has been correctly Selected. The slope is between 0 and 1.0
E N D
Circle Scan Conversion We assume the following – The circle centered at (0,0) – We draw 1/8 of the circle, Then use 8-way symmetry Not 8-way Symmetry Compute Graphics
Circle Scan Conversion We assume (xp, yp) has been correctly Selected. The slope is between 0 and 1.0 If the circle passes above M, then We select E Else We select SE E M ME SE MSE We assume – The circle centered at (0,0) – We draw 1/8 of the circle, Then use 8-way symmetry Compute Graphics
E M ME SE MSE Circle Scan Conversion We use D as in the case of line D = F(M) = F(xp+1, yp-0.5) = (xp+1)2+(yp-0.5)2-R2 If ( D < 0 ) then M is below the arc, pixel E is closer to the line. If (D >= 0 ) then M is above the arc, pixel SE is closer to the line. Compute Graphics
E M ME SE MSE Circle Scan Conversion CASE I: E is next We use D as in the case of line Dnew = F(ME) = F(xp+2, yp-0.5) = (xp+2)2+(yp-0.5)2-R2 = D + ( 2*xp+3) CASE II: SE is next We use D as in the case of line Dnew = F(M) = F(xp+2, yp-1.5) = (xp+2)2+(yp-1.5)2-R2 = D + ( 2*xp-2yp+5) Initialization Dinit=F(1,R-0.5)= Compute Graphics
E M ME SE MSE Circle Scan Conversion DrawCircel(int radius, Color clr){ int x = 0 ; int y = radius ; int d = 1-radius ; Plot(x,y, clr); while ( y > x ){ if ( d < 0 ) // E Selected d += 2*x + 3 ; else { d += 2*(x-y) + 5 ; y-- ; } x++ ; Plot(x,y, clr); } } Compute Graphics
Circle Scan Conversion Let us use second order difference If E was selected then Eold = 2xp+3 Enew = 2(xp+1)+3 deltaE = Enew-Eold= 2 If SE was selected then SEold = 2xp-2yp+5 SEnew = 2(xp+1)-2yp + 5 deltaSE = SEnew-SEold= 4 E M ME SE MSE Compute Graphics
E M ME SE MSE Circle Scan Conversion DrawCircel(int radius, Color clr){ int x = 0 , y = radius ; int d = 1-radius ; int deltaE = 3, deltaSE = -2*radius + 5 ; Plot(x,y, clr); while ( y > x ){ if ( d < 0 ){ // E Selected d += deltaE ; deltaE +=2 ; deltaSE +=2 ; else { // SE Selected d += deltaSE ; deltaE += 2 ; deltaSE += 4 ; y-- ; } x++ ; Plot(x,y, clr); } } Compute Graphics