射线-胶囊相交
我有一个由两点 A
和 B
以及半径 r
定义的胶囊。射线由方程式定义:X = O + D*t
。现在我需要获取所有(0-2)交点的t
。
一种可能的解决方案是计算 A
和 B
处与球体的交集以及与圆柱体的交集。然后,因为胶囊是凸的,所以我只取所有结果 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要测试胶囊是否与射线相交,只需测试线段交叉点
A
和B
与射线之间的距离。如果距离小于半径r则有两个交点,如果相等则有一个接触点。要计算交集,请按照您的描述进行操作。
To test whether a capsule intersects a ray line just test distance between the line segment crossing points
A
andB
and the ray line. If the distance is smaller than radiusr
then there are two intersecting points, if is equal there is one touching point.To calculate intersection do as you described.
使用射线和线段之间的最近点并不在所有情况下都有效,如果射线位于胶囊的半径内并且与胶囊大致平行/浅角度,则可能会导致在胶囊的另一端计算碰撞胶囊
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
只是猜测:维基百科的意思是两个胶囊的相交,它确实似乎比两个圆柱体的相交更简单。
我会像你所描述的那样搜索交点......
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...