圆形物体的碰撞 [英] Collision of circular objects

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

问题描述

我要发展碰击棋盘游戏。我在使用两件的碰撞的问题。如何找到的两片碰撞点。再怎么找角度和距离的出行件后collision.I发现碰撞点的解决方案,在 circle-圆碰撞。这里的解决方案与三角描述,但我想与向量运算解决方案。与覆盖碰撞后的距离的问题也将很容易地解决。

I'm going to develop carom board game. I'm having the problem with the collision of two pieces. How to find the collision point of two pieces. And then how to find the angle and distance the pieces travel after collision.I found the solution of the collision point at circle-circle collision. here the solution is described with trigonometry, but I want the solution with vector math. With which the problem of the distance covered after collision will also be solve easily.

推荐答案

您并不需要找到碰撞点碰撞计算本身。为了检测碰撞事件,你只需要比较中心的距离去半径之和

You do not need to find the collision point for the collision computation itself. To detect a collision event, you only need to compare the distance of the centers go the sum of radii

sqrt(sqr(x2-x1)+sqr(y2-y1))<=r1+r2

dx*dx+dy*dy <= (r1+r2)*(r1+r2)

其中,(X1,Y1)(x2,y2)是磁盘1(位置与质量 M1 ,半径 R1 和速度(VX1,VY1) )和2差异总是2减1, DX = X2-X1 等。

where (x1,y1) and (x2,y2) are the positions of disks 1 (with mass m1, radius r1 and velocity (vx1,vy1)) and 2. Differences are always 2 minus 1, dx=x2-x1 etc.

您会几乎从来没有得到的碰撞发生在时间离散采样时间。与上述式中,圆圈已经有重叠。根据时间和步骤一般速度,这可能是可以忽略不计,或可能导致严重的过冲。下面简单的计算假设慢动作,也就是说,在过去的时间步长非常小的重叠。

You will almost never get that the collision happens at the sample time of the time discretisation. With the above formula, the circles already have overlap. Depending on time step and general velocities this may be negligible or can result in severe over-shooting. The following simple computation assumes slow motion, i.e., very small overlap during the last time step.

这是发生在非旋转磁盘的完全弹性碰撞的唯一的事情是在速度变化。这种变化有可能只发生一次,当进一步的运动将进一步降低的距离,也就是说,如果

The only thing that happens in the fully elastic collision of non-rotating disks is a change in velocity. This change has to happen only once, when further movement would further reduce the distance, i.e., if

dx*dvx+dy*dvy < 0

其中, DVX = VX2-VX1 等。

使用这些想法,计算如下(见 http://stackoverflow.com/a/23193044/3088138详细内容)

Using these ideas, the computation looks like this (see http://stackoverflow.com/a/23193044/3088138 for details)

dx = x2-x1; dy = y2-y1;
dist2 = dx*dx + dy*dy;
R = r1+r2;

if ( dist2 <= R*R )
{
    dvx=vx2-vx1; dvy=vy2-vy1;
    dot = dx*dvx + dy*dvy;

    if ( dot < 0 )
    {
        factor = 2/(m1+m2)*dot/dist2;
        vx1 += m2*factor*dx;
        vy1 += m2*factor*dy;
        vx2 -= m1*factor*dx;
        vy2 -= m1*factor*dy;
    }
}

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

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