Finding a coordinate in a circle

后端 未结 7 1230
梦谈多话
梦谈多话 2021-01-06 20:51

I am doing a mashup using Google Maps under Grails where users can create geofences by selecting a point on the map and a radius. This get stored on my database and the appl

7条回答
  •  死守一世寂寞
    2021-01-06 21:16

    You want to find the vector that is the distance between the selected coordinate and the center of the circle, then compute the square distance between the selected coordinate and the center of the circle by squaring the components of the vector and adding them together; if that scalar (the squared distance) is less than the square of the radius, the point is within the circle.

    This method avoids having to take a square root, and is just as accurate as normal distance comparison.

提交回复
热议问题