MidPoint Circle AlgorithmIt 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 This is called midpoint (xi+1,yi- Pi=f (xi+1,yi- If Pi is -ve ⟹midpoint is inside the circle and we choose pixel T If Pi is+ve ⟹midpoint is outside the circle (or on the circle)and we choose pixel S. The decision parameter for the next step is: Pi+1=(xi+1+1)2+(yi+1- Since xi+1=xi+1, we have ![]() If pixel T is choosen ⟹Pi<0 We have yi+1=yi If pixel S is choosen ⟹Pi≥0 We have yi+1=yi-1 ![]() We can continue to simplify this in n terms of (xi,yi) and get ![]() Now, initial value of Pi (0,r)from equation 2 ![]() We can put Algorithm:Step1: Put x =0, y =r in equation 2 Step2: Repeat steps while x ≤ y Step3: End Program to draw a circle using Midpoint Algorithm:Output: ![]()
Next TopicScan converting a Ellipse
|