矩形与箭头的碰撞检测
我想检测矩形和箭头之间的碰撞。最好的算法或方法是什么?
我尝试实现分离轴定理,但对于以下情况,我得到碰撞 = true 这是错误的。
另外,箭头是凸多边形吗?
感谢您的帮助。
问候
I want to detect collision between a rectangle and an arrow. What is the best algorithm or method for that?
I tried to implement Separating Axis Theorem but for following case i get collision = true which is wrong.
Also, is an arrow a convex polygon?
Thanks for help.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
箭头是凹形。
最简单的方法可能是将箭头视为两个单独的形状:矩形和三角形。检查矩形与矩形的碰撞非常简单,对于三角形(凸),您可以使用任何代码来检查凸多边形。如果任一返回 true 碰撞,则返回 true;否则,返回 false。
希望这有帮助。
An arrow is concave.
The easiest way to do this would probably be to treat the arrow as two separate shapes: a rectangle and a triangle. Checking for a rectangle-to-rectangle collision is pretty easy, and for the triangle (which is convex) you could use whatever code you have for checking against convex polygons. If either returns true for collision, return true; otherwise, return false.
Hopefully that helps.