球碰撞问题 [英] Ball collision problems

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

问题描述

所以我有撞击球的通常工作,除非他们有相似的方向进行碰撞,小于90度分开的系统。

So I have a system with colliding balls that generally works, except for when they collide with similar directions, less than 90 degrees apart.

这是因为球上述尝试冲撞黄线,是假想碰撞面,但它把它发送错误的方向,并且它跟随的其他球。一般的算法碰撞是:

This is because the ball above tries to collide against the yellow line which is supposedly the collision plane, but it sends it off the wrong direction, and it "follows" the other ball. The general algorithm for the collision is:

dot = direction.surface;
parallel = surface * dot;
perpendicular = direction - parallel;
direction = perpendicular - parallel;

哪个否定平行于表面法线,其垂直于碰撞平面的方向的分量,并垂直于表面法线部分是不变的。

Which negates the component of the direction parallel to the surface normal, which is perpendicular to the collision plane, and the part perpendicular to the surface normal is unchanged.

有谁知道这是一个解决?我做错了?

Does anyone know a fix for this? Have I done something wrong?

编辑:所以,现在我又说:

So now I added:

average = (ball1.velocity + ball2.velocity) / 2;
ball1.velocity -= average;
ball2.velocity -= average;

在做上述的计算,之后

ball1.velocity += average;
ball2.velocity += average;

要得到正确的参照系,根据@ Beta版的答案。现在的问题是,球的速度是不能维持的,因为它们都具有相同的速度和质量,但碰撞后,他们是不同的。我不认为这是应该发生的,是这样吗?

To get in the right reference frame, according to @Beta's answer. The problem now is that the speeds of the balls aren't maintained, since they both have the same speeds and masses, yet after the collisions they're different. I do not think this is supposed to happen, or is it?

推荐答案

考虑弹跳球掀起了墙上的一维问题。简单的。

Consider the 1D problem of bouncing a ball off a wall. Simple.

现在看我弹跳球掀起了喷气式飞机在飞行前舱壁。球北移252米/秒,隔壁正在向北250米/秒。答案并不明显。但是,转移到我的坐标系(减去舱壁速度250米/秒,从一切),问题是微不足道的。解决这个问题,那么(通过的添加 250℃米/秒的一切),你就大功告成了。

Now watch me bounce a ball off the forward bulkhead of a jet plane in flight. The ball is moving north at 252 m/s, the bulkhead is moving north at 250 m/s. The answer is not obvious. But shift into my coordinate frame (by subtracting the velocity of the bulkhead, 250 m/s, from everything) and the problem is trivial. Solve it, then shift the result back into the ground frame (by adding 250 m/s to everything) and you're done.

现在一个球反弹的壁成一角度的二维问题。简单。 (但请确定您的code正确地做它。)

Now the 2D problem of a ball bouncing off a wall at an angle. Simple. (But verify that your code does it correctly.)

现在两个球与相等,方向相反的动量碰撞(我假设他们有相同的质量,目前如此)。你能想象一个黄墙的碰撞平面,答案来得容易。

Now two balls colliding with equal and opposite momenta (I'll assume they have the same mass, for now). You can imagine a yellow wall at the collision plane, and the answer comes easily.

现在两个球碰撞,但随着速度的做的没有的加起来为零。仍然有黄墙,但它的移动。好了,转移到墙的框架减去球从一切速度(总和/ 2)的平均水平,解决简单的问题,再移回通过添加相同的速度回了一切,你就大功告成了。

Now two balls colliding, but with velocities that do not add up to zero. There's still a yellow wall, but it's moving. Well, shift into the wall's frame by subtracting the average of the balls' velocities (sum/2) from everything, solve the simpler problem, then shift back by adding that same velocity back to everything, and you're done.

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

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