Determine whether a point falls into a circle

Good afternoon. The database stores the coordinates of a point (float type) from google-maps. When getting such coordinates, you need to determine which points stored in the database fall into the circle of the received point. I.e., there is a coordinate in the base 5, 5. Coordinate 6, 6 is received. There is a certain radius (say 5 meters), you need to find out whether 6, 6 falls into the circle. The question seems not complicated, but I can't figure out how to calculate all this correctly

Author: Nofate, 2013-08-13

1 answers

You can use the following condition:

(x - x0)^2 + (y - y0)^2 <= R^2

Where x and y are the coordinates of your point, x0 and y0 are the coordinates of the center of the circle, R is the radius of the circle, and ^2 is the squaring. If the condition is met, then the point is inside (or on the circle, if the left and right parts are equal). If not, then the point is outside the circle.

Necessary clarification - this will work in the case of small radii (up to several kilometers). In the case of circles with with large radii, the assumption that the surface is flat will become incorrect - you will need to take into account the curvature of the Earth's surface and make adjustments taking into account the spatial geometry

 12
Author: DreamChild, 2013-08-13 08:27:27