如何找到圆的重叠部分
您好,我制作了一个有两个球的应用程序。红色和黄色。 用户必须拖动红球
并将其放在黄球
上。它位于 XY 平面中。现在我想计算重叠的精度是多少。我知道如果目标的 XY 等于前锋的 XY,那么它就是 100%,但是你将如何计算它呢?就好像你将红球向右移动,前锋的 X 值变大,百分比将不准确?我一直在使用百分比误差公式,但它不准确
double percentErrorX =(CurrentX-targetX)*100/targetX;
double percentErrorY = (CurrentY -targetY)*100/targetY;
Hi there I made an application which has two balls.Red and Yellow.
User has to drag RED BALL
and drop it over the YELLOW BALL
.it is in X-Y Plane.now i want to calculate what is the accuracy is the overlapping. I know that if the X-Y of target are equal to the X-Y of the Striker then it is 100 percent but how will you calculate it? as if you move the red ball further right value of X of striker gets bigger and percent will not be accurate?I have been using Percent Error formula but it is not accurate
double percentErrorX =(CurrentX-targetX)*100/targetX;
double percentErrorY = (CurrentY -targetY)*100/targetY;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为最直观的百分比计算形式是计算每个重叠圆的面积百分比。
您使用什么样的粒度?你的 xy 坐标代表什么,每个圆的中心?如果 xy 坐标为中心,则可以使用距离公式:
其中目标的 xy 坐标为 x1、y1,前锋的 xy 坐标为 x2、y2。
使用这个 d,您可以像这样计算百分比:
I would think the most intuitive form of percentage calculation would come from computing the percentage of area of each circle that is overlapping.
What kind of granularity are you using? And what does your x-y coordinate represent, the center of each circle? If the x-y coordinate is the center, then you could use the distance formula:
Where the x-y coords of the target are x1, y1 and the x-y coords of the striker are x2, y2.
With this d, you can computer a percentage like so:
看看 Wolfram 的这个精彩页面
Have a look at this wonderful page at Wolfram
碰撞有很多种类型。还有一篇关于圆形碰撞的好文章:
http://compsci.ca/v3/viewtopic.php?t=14897
there're many of types of collision. and a good article for circle collision :
http://compsci.ca/v3/viewtopic.php?t=14897
您需要一些数学来计算准确的结果,但这里有一种饮食方法可以为您提供良好的近似值。
通过 sqrt((x1-x2)^2+(y1-y2)^2) 计算球之间的距离
您的结果约为(距离/半径*2)^1.8
尝试这样的公式,看看精度是否足够好
You need some math to calculate the exact result but here is an eat way that will give you good approximation.
Calculate the distance between the balls by sqrt((x1-x2)^2+(y1-y2)^2)
Your result is approximately (distance/radius*2)^1.8
try thus formulae and see if the precision is good enough