Kaow
Kaow

Reputation: 563

How to know if a point is locate at outer circle?

Having a circle with the centre (xc,yc) with the radius r how to know whether a point (xp,yp) is locate at the outer circle which following in the picture below.

enter image description here

Upvotes: 0

Views: 34

Answers (1)

MBo
MBo

Reputation: 80325

If inner circle has radius r and outer circle has radius R, then you can check whether point lies in the ring using comparison of squared distances:

 dd = (xp - xc)^2 + (yp - yc)^2
 if (dd <= R^2) and (dd >= r^2) then 
    point is in the ring

Upvotes: 1

Related Questions