MidPoint Circle Algorithmnew
MidPoint Circle Algorithmnew
It is based on the following function for testing the spatial relationship between the
arbitrary point (x, y) and a circle of radius r centered at the origin:
Now, consider the coordinates of the point halfway between pixel T and pixel S
6.8M
148
OOPs Concepts in Java
If Pi is+ve ⟹midpoint is outside the circle (or on the circle)and we choose pixel S.
We have yi+1=yi
We have yi+1=yi-1
We can put ≅1
∴r is an integer
So, P1=1-r
OR( those who want to know complete derivation can learn below II derivation) or you can write the
above only
Or
II Complete derivation steps(those who needed only )
For that decision Mid Point circle drawing technique will us decide
our next pixel whether it will be N or S.
As is the next most pixel of therefore we can write,
(x– h)2 + (y – k)2 = r2
Now,
Pk+1- Pk = (xk+1+1)2 + (yk+1 -1/2)2 - r2
-[(xk+1)2 + (yk -1/2)2 - r2]
= ((xk+1)+1)2 + (yk+1 -1/2)2
- (xk+1)2 - (yk -1/2)2
Pk = (xk+1)2 + (yk -1/2)2 - r2
P0 = (0+1)2 + (r -1/2)2 - r2
= 1 + r2 + ¼ - r – r2
= 1 + ¼ - r
as xk+1 = xk+1 , therefore,
Pk+1 = Pk + 2xk+1 +1