Find if points are within a circle with given cent

2019-03-16 12:48发布

We have a point (x,y) and a set of some other points (xi,yi). How can we determine which of (xi,yi) are within a circle with center (x,y) and radius r (a given number)?

标签: circle
5条回答
相关推荐>>
2楼-- · 2019-03-16 13:15
(xi-x)**2 + (yi-y)**2 < r**2
查看更多
三岁会撩人
3楼-- · 2019-03-16 13:17

If (xi - x)^2 + (yi - y)^2 is less than d^2, it's inside. If it equals d^2, it's on the circle. If it's greater than d^2, it's outside.

查看更多
何必那么认真
4楼-- · 2019-03-16 13:21

If sqrt((xi-x)^2 + (yi-y)^2) <= d

查看更多
\"骚年 ilove
5楼-- · 2019-03-16 13:23

I had the same problem to solve inside a plsql procedure. The solution above are completely right and I did the same. But it compromised the performance of my plsql program drastically. Instead of that circle calculation, I used a square. Because it can be done without doing such calculation and in the sql statement itself. It improved the query performance by more than 10x

查看更多
家丑人穷心不美
6楼-- · 2019-03-16 13:29

Simple way.

Compute the distance from the point to the center of the circle. If less than radius , then its within the circle.

查看更多
登录 后发表回答