两个圆圈的碰撞 [英] Collision of Two Circles

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

问题描述

嘿,我正在用java编写一个程序(但我认为那与这个问题没什么关系),两个机器人(圆圈)正在驾车。
机器人以某种速度从某个特定位置行驶到特定位置。
问题是如何确定有碰撞的圆圈。
我不能使用圆的中点和矢量的移动,导致圆有半径。
另一个问题是我无法检查圈子的最终位置。
我需要检查路上是否有碰撞,以及是否在同一时间。
有没有人有一个想法如何计算?




<让我们 P1 =(x1,y1) P2 =(x2,y2)解析方案

是起始坐标, V1 =(vx1,vy1) V2 =(vx2,vy2)是速度, R1 R2 是圆辐射。
如果中心距小于 R1 + R2 (或者平方距离小于 RR =(R1 + R2) )我们可以找到中心的坐标,距离与时间的函数,并确定距离是否变得足够小。

简单的方法 - 使用伽利略原理,在坐标系中工作,与第一个对象链接。在该系统中,它停留在零点,第二个对象以起点(x2-x1,y2-y1)和速度( vx2-vx1,vy2-vy1)
第二个对象在整个时间的坐标:

  X =(x2-x1)+(vx2-vx1) * t = dx + vx * t 
Y =(y2-y1)+(vy2-vy1)* t = dy + vy * t

碰撞发生时,平方距离和RR之间的差值为零

  D ^ 2 -  RR = X * X + Y * Y  -  RR = 
dx ^ 2 + 2 * dx * vx * t + vx ^ 2 * t ^ 2 + dy ^ 2 + 2 * dy * vy * t + vy ^ 2 * t ^ 2 - RR =
(vx ^ 2 + vy ^ 2)* t ^ 2 + 2 *(dx * vx + dy * vy)* t +(d​​x ^ 2 + dy ^ 2- RR)= 0

求解 t 。如果存在适当的(积极的,最小的积极的)根,那么碰撞就发生在这一刻。


Hey i am writing a program in java (but i think thats not that relevant for this question), where two robots (circles) are driving arround. A robot is driving with a certain speed from a certain location to a certain location. Problem is how to determine if the circles having a collision. I cant use the midPoint of the circle and the vector its moving, cause the circle have a radius. Another problem is I just can't check the final locations of the circles. I need to check if the collide on the way and if it is in the same time. Does anyone have an idea how to calculate that?

解决方案

Let's P1 = (x1, y1) and P2 = (x2, y2) are starting coordinates, V1 = (vx1, vy1) and V2 = (vx2, vy2) are velocities, R1 and R2 are circle radia. Circles collide, if center-center distance is smaller than R1 + R2 (or squared distance is smaller then RR=(R1+R2)^2)

We can find coordinates of centers, function of distance versus time, and determine whether distance ever becomes small enough.

Simple approach - using Galileo's principle, working in coordinate system, linked with the first object. In that system it stays in the zero point, and the second object is moving with starting point (x2-x1, y2-y1) and velocity (vx2-vx1, vy2-vy1). Coordinates of the second object through the time:

X = (x2-x1) + (vx2-vx1) * t = dx + vx * t
Y = (y2-y1) + (vy2-vy1) * t = dy + vy * t

Difference between squared distance and RR is zero when collision occurs

D^2 - RR = X*X + Y*Y - RR = 
dx^2 + 2*dx*vx * t + vx^2 * t^2 + dy^2 + 2*dy*vy * t + vy^2 * t^2 - RR = 
(vx^2+vy^2) * t^2 + 2*(dx*vx+dy*vy) * t + (dx^2+dy^2-RR) = 0

Solve last quadratic equation against t. If proper (positive, the smallest positive) root exists, then collision occurs in this moment.

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

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