Search code examples
geometrypythagorean

How to calculate the total number of circle coordinates?


If having a centre(xc,yc) and radius(r), how can i calculate total number of coordinates(x,y) in the circle?


Solution

  • I suspect that you are talking about integer points in the circle. Otherwise question is senseless.

    In this case you can apply Gauss formula

    N = 1 + 4 * r + 4 * sum[i=1..r]{floor(sqrt(r^2-i^2))}
    

    Note that center has integer coordinates too.