与扭矩的碰撞响应

发布于 2024-11-02 00:28:43 字数 490 浏览 4 评论 0原文

我正在编写一个 2D 刚体模拟器。被模拟的物体是凸多边形。我的问题涉及如何确定碰撞的“点”,以便当我施加响应力时,我还可以计算扭矩。

在二维中,窄相碰撞检测的流行方法似乎是分离轴定理。然而,虽然这给了你“他们在碰撞吗?”以及“多少?”,它不会为您提供一个参考点(我知道)来施加响应力(从而计算扭矩)*。

另一种方法(这也让我更感兴趣,因为它是 3D 中使用的方法,这将是合乎逻辑的下一步)是计算两个多边形的 Minkowski 差,如果 (0,0) 为,则确定它们发生碰撞包含在生成的多边形中。但是,如何使用它来决定施加响应力的相对点?我的假设是,由于这种差异的每个面实际上对应于其中一个多边形的一个面,因此分隔距离是从 (0,0) 到 MD 的最短距离,并将其应用于多边形上的相应面。

作为奖励,如何在 3D 中做到这一点?

*当我写这篇文章时,我刚刚意识到,在使用 SAT 时,我可以跟踪哪些点重叠,并在这些点的“平均值”处施加力。但我必须决定在几个非分离轴中的哪一个来执行这个小技巧......

I'm writing a 2D rigid body simulator. The objects being simulated are convex polygons. My question involves how to decide on the "point" of collision, so that when I apply a response force, I can also calculate torque.

In 2D, the popular method of narrowphase collision detection seems to be the Separating Axis Theorem. However, while this gives you the "are they colliding?" as well as "by how much?", it does NOT give you a reference point (that I'm aware of) at which to apply the response force (and thus calculate torque)*.

The other method (which also interests me more, because it's what's used in 3D, which would be the logical next step) is to calculate the Minkowski difference of the two polygons, and decide that they're colliding if (0,0) is contained in the resulting polygon. But, how do you use this to decide the relative point at which to apply the response force? My hypothesis is that, since each face of this difference effectively corresponds to a face of one of the polygons, the separation distance is the shortest distance from (0,0) to the MD, and you apply this to the corresponding face on the polygon.

As a bonus, how does one do this in 3D?

*As I'm writing this, I just realized that, when using SAT, I could just keep track of which points are overlapping, and apply the force at the "average" of those points. But I would have to decide on which of the several non-separating axes to perform this little trick...

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

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

发布评论

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

评论(1

柠檬色的秋千 2024-11-09 00:28:43

这是我曾经做过的,但有很多可能的解决方案:

分离轴定理将为您提供从一个物体到另一个物体的方向,该方向垂直于分离轴(或 3D 中的分离平面)。您可以使用该方向与凸体上的每个点来获取穿透距离,或每个点沿该方向距分离轴或平面的距离。

按穿透距离对点进行排序。从最具穿透力的点开始,如果它在另一个身体内部,则您已找到第一个接触点,否则继续下一个接触点。您可能希望继续查找沿分离方向距第一个接触点一定距离范围内的其他接触点。将这些点作为“接触流形”进行跟踪。对流形中的点进行平均,或使用其他方法来确定施加接触力的点。

一些先进的技术:

将接触流形保留在内存中将使您可以通过首先测试前一个流形来有效地测试下一帧。

对于连续碰撞检测,用测试框架内每个点的路径(近似为线段)是否以及在何处与另一个物体相交的测试来代替该点是否在另一个物体内部的测试。这要昂贵得多,但可以防止小型快速移动的物体穿过薄壁。

Here's how I did it once, but there are many possible solutions:

Separating axis theorem will give you a direction from one body to another, this direction is perpendicular to the separating axis (or separating plane in 3D). You can use this direction with each point on the convex bodies to get the penetration distance, or the distance of each point from the separating axis or plane along the direction.

Sort the points by their penetration distance. Begin with the point that is most penetrating and if it is inside the other body, you have found the first point of contact, otherwise proceed to the next. You probably want to continue finding additional points of contact that are within some threshold of distance from the first contact point along the separating direction. Track these points as a 'contact manifold'. Average the points in the manifold, or use some other method, to determine the point to apply the contact force.

Some advanced techniques:

Keeping the contact manifold in memory will allow you to efficiently test on the next frame by testing the previous manifold first.

For continuous collision detection, replace the test of whether the point is inside the other body with a test of whether and where the path of each point within the frame (approximated as a line segment) intersects the other body. This is much more expensive but prevents small, fast-moving objects from tunneling through thin walls.

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