Kaow
Kaow

Reputation: 563

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?

Upvotes: 0

Views: 38

Answers (1)

MBo
MBo

Reputation: 80187

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.

Upvotes: 1

Related Questions