计算弹跳圆/球的结果向量

发布于 2024-12-27 22:47:15 字数 561 浏览 2 评论 0原文

我一直在努力根据 2 个弹跳圆/球获得正确的矢量值。我知道他们什么时候弹起;使用毕达哥拉斯,但后来我迷路了。我知道我可能必须使用三角函数 cos/sin/tan2。

这种情况,用我的图片解释 image
(来源:microshift.net

找到了几个例子网上有,但即使有了这些,我还是无法弄清楚!

此处进行了 2 个 HTML5 实验。

在一个示例中,第二个/较大的球是静态的,在另一个示例中,可以通过移动鼠标光标来移动较大的球。

您能给出一个基于已知变量的计算示例吗?

I've been struggling with getting to the right vector values based on 2 bouncing circles/balls. I know when they bounce; using Pythagoras, but then I'm lost. I know I would probably have to use trigonometry cos/sin/tan2.

The situation, explained in my image
image
(source: microshift.net)

Found a couple of examples online, but even with those, I can't figure it out!

Made 2 HTML5 experiments over here.

In one of the examples the 2nd/bigger ball is static, in the other example the larger ball can be moved by moving the mouse cursor.

Can you please give an calculation example based on the known variables?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街道布景 2025-01-03 22:47:15

您基本上想要使用动量守恒(总是)和能量守恒(假设您想要完美的弹性碰撞)。一个漂亮的小图形和方程显示在此处。 (在图形中,物体大小相同,但大小并不重要。重要的是两个圆或球体的质量以及碰撞时两个表面之间的直线或平面的角度 - - 它将垂直于具有中心和接触点的线。)

这是基础知识,然后您可以通过以下方式处理不同的变化:

两个物体在撞击时都在移动的情况
为了处理两个对象都在移动的情况,最简单的方法是转换为其中一个对象静止的参考系,然后再转换回来。也就是说,从对象 #1 和 #2 中减去对象 #2 的矢量速度(使对象 #2 为零速度),进行计算,然后将相同的矢量速度添加到两个对象。当然,您可以写出完整的方程式,但转换和转换回来会更容易。

整个箱子固定一个物体
如果你想固定其中一个物体,你只需使用入射角等于反射角,即找到切平面(3D)或线(2D) )在撞击时(这只是与中心之间的线垂直的线或平面,也包括接触点)并将物体从该平面/线上弹开。 (您可以在方程中看到,这基本上是一个物体具有无限质量的情况,有时这样做更容易,如果说,您已经为两个可以自由移动的物体编写了这个。)

< strong>用鼠标光标移动一个对象的情况:
如果用鼠标光标移动一个对象,我假设您希望它看起来具有无限质量,也就是说,光标将对象完全固定在光标的位置。在这种情况下,只需结合前两种情况,即将所有运动转换为光标对象的参考系(通过从所有内容中减去其速度),对保持固定的对象进行计算,然后添加相同的值再次变回的速度。 (恕我直言,让光标对象可移动但由阻尼弹簧固定在光标的位置看起来也不错,但这是一个单独的问题。)

You basically want to use conservation of momentum (always) and conservation of energy (assuming you want a perfectly elastic collision). A nice little graphic and the equations are shown here. (In the graphic, the objects are the same size, but the size doesn't matter. All that matters is the mass of the two circles or spheres and the angle of the line or plane between the two surfaces at the moment of collision -- which will just be perpendicular to the line that has the centers and contact point.)

That's the basics, then you can deal with the different variations in the following ways:

case both objects are moving at time of impact:
To deal with the case when both objects are moving, it's easiest to transform into a reference frame where one is stationary, and then back again. That is, subtract the vector velocity of object #2 from both objects #1 and #2 (giving object #2 zero velocity), do the calculation, and then add this same vector velocity to both objects. You could, of course, write down the full equation for this, but it's easier to just transform and transform back.

case for one object held fixed throughout:
If you want to hold one of the objects fixed, you just use angle of incidence equal angle of reflection, that is, find the tangent plane (3D) or line (2D) at the time of impact (this will just be the line or plane perpendicular to the line between the centers, that will also include the point of contact) and bounce the object off this plane/line. (You can see in the equations that this is basically the case where one object has infinite mass, and sometimes it's easier to just do it this way, if say, you've already written this for both objects being free to move.)

case for one object moved with mouse cursor:
If one object is moved with the mouse cursor, I assume you want it to look like it has infinite mass, that is, the cursor completely pins the object exactly at the cursor's location. In this case, just combine the previous two cases, that is, transform all motions into the reference frame of the cursor's object (by subtracting its velocity from everything), do the calculation as for the object being held fixed, and then add the same velocity to transform back again. (It would also look good, imho, to have the cursor object movable but held by a damped spring to the cursor's location, but that's a separate issue.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文