开发者

how to find overlapping of circle

Hi there I made开发者_如何学Python 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;

how to find overlapping of circle


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:

d = sqrt[ (x1-x2)^2 + (y1-y2)^2 ]

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:

Percent = (d / radius)


Have a look at this wonderful page at Wolfram


there're many of types of collision. and a good article for circle collision : http://compsci.ca/v3/viewtopic.php?t=14897


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜