找一个圆的坐标 [英] Finding a coordinate in a circle

查看:20
本文介绍了找一个圆的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Grails 下使用 Google 地图进行混搭,用户可以通过选择创建地理围栏地图上的一个点和一个半径.这将存储在我的数据库中,应用程序不断从 GPS 设备接收一组坐标.

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 application receives constantly a set of coordinates from a GPS device.

我想将接收到的坐标与存储在圆圈中的区域进行比较.如果点在圆的内部(或外部),程序将触发一个动作.但是,我想知道如何确定坐标是否位于圆内/外.有一个 Javascript 库允许执行此操作,但我需要在服务器上执行此操作.

I would like to compare the received coordinates with the area stored in the circles. If the point is inside (or outside) the circle the program will fire an action. However, I would like to know how I can find out if the coordinates are located inside/outside the circle. There is a Javascript library which allows doing this but I need to do this on the server.

是否有用于此的 Java(甚至 Groovy)库?您将如何实施?

Is there a Java (or even Groovy) library for this? How would you implement it?

推荐答案

如果圆心的距离是<=圆的半径 那么它就在圆圈内.
如果该区域由一个以上的圆组成,而不是由所有圆组成...不会花那么长时间.

if distance from point to center of circle is <= radius of circle then it is inside the circle.
if the area is made of more than one circle than compare to all the circles... it won't take that long.

java.awt.geom.Point2D.Double 非常适合这个.

java.awt.geom.Point2D.Double is perfect for this.

这篇关于找一个圆的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆