射线-胶囊相交

发布于 2024-11-29 08:46:42 字数 397 浏览 4 评论 0原文

我有一个由两点 AB 以及半径 r 定义的胶囊。射线由方程式定义:X = O + D*t。现在我需要获取所有(0-2)交点的t

一种可能的解决方案是计算 AB 处与球体的交集以及与圆柱体的交集。然后,因为胶囊是凸的,所以我只取所有结果 t 值的最小值和最大值。

但正如wikipedia所述,胶囊相交测试应该比圆柱体相交测试更简单。有人可以向我指出一种有效的胶囊射线相交算法吗?

I have a capsule defined by two points A and B and radius r. The ray is defined by equation: X = O + D*t. Now I need to get t for all (0-2) intersection points.

One possible solution would be to calculate intersection with spheres at A and B and intersections with cylinder. Then because capsule is convex I would just take minimum and maximum of all resulting t values.

But as wikipedia states, capsule intersection test should be even simpler than cylinder intersection test. Could somebody point me to an efficient capsule-ray intersection algorithm?

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

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

发布评论

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

评论(3

む无字情书 2024-12-06 08:46:42

要测试胶囊是否与射线相交,只需测试线段交叉点 AB 与射线之间的距离。如果距离小于半径r则有两个交点,如果相等则有一个接触点。

要计算交集,请按照您的描述进行操作。

To test whether a capsule intersects a ray line just test distance between the line segment crossing points A and B and the ray line. If the distance is smaller than radius r then there are two intersecting points, if is equal there is one touching point.

To calculate intersection do as you described.

桜花祭 2024-12-06 08:46:42

使用射线和线段之间的最近点并不在所有情况下都有效,如果射线位于胶囊的半径内并且与胶囊大致平行/浅角度,则可能会导致在胶囊的另一端计算碰撞胶囊

using the closest point between the ray and segment doesn't work in all circumstances if the ray is within the radius of the capsule and roughly parallel/shallow angle to the capsule then it can result in the collision being computed a the other end of the capsule

酒解孤独 2024-12-06 08:46:42

只是猜测:维基百科的意思是两个胶囊的相交,它确实似乎比两个圆柱体的相交更简单。

我会像你所描述的那样搜索交点......

Just a guess: Wikipedia means intersection of two capsules, it indeed seems to be simpler that intersection of two cylinders.

I would search for intersection points just as you described...

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