calculate pixels for a circle with radius 10 using bresenham algorithm
Answers
Explanation:
the Bresenham circle drawing algorithm, we have to choose between the top and bottom pixel, but what we always do is using the circle's equation (f(x,y)=x2+y2=r2) to determine which of the two pixels is closer to the circle (r is the radius).
For the top pixel (N), we thus have f(N)=x2k+1+y2k−r2
And for the bottom pixel (S), we have f(S)=x2k+1+y2k−1−r2
Okay, we're using the circle equation to determine which is the closest point to the circle but why not simply using the euclidean distance? What is the point to use f instead of the actual distance? It would be easier to understand (this f function seems to come out of nowhere).
The actual distance between the top pixel and the circle is x2k+1+y2k−−−−−−−−√−r and with the bottom pixel it's r−x2k+1+y2k−1−−−−−−−−−√.