奇怪形状的多边形的碰撞检测
我计划制作一个程序,其中有一些圆形形状在形状奇怪的多边形内移动。
我似乎无法弄清楚如何对边缘进行碰撞检测并使形状正确反弹。
我确信这个问题以前已经解决了,但我找不到一个很好的例子。
我的主要问题是: 确定圆是否触及其周围多边形的边缘。 一旦发生击中,计算击中点的法线以计算出反射矢量。
有人能指出我正确的方向吗?
谢谢,杰森
I am planning to make a program which will have some circular shapes moving inside of a oddly shaped Polygon.
I can't seem to figure out how to do the collision detection with the edges and have the shapes bounce back correctly.
I am sure this problem has been solved before, but I can't find a nice example.
My main problems are:
Figuring out if the circle has hit the edge of its surrounding polygon.
Once a hit occurs calculate the normal of the hit point to figure out the reflection vector.
Can anyone point me in the right direction?
Thanks, Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要进行圆线相交测试。
为了使其更快,您可以首先检查边界框。例如,如果直线的起点和终点都在圆的最左边坐标的左侧,则不能有交点。
You need to do a circle line intersection test.
To make it faster, you can first check the bounding boxes. For example, if the start and end point of the line are both to the left of the leftmost coordinate of the circle, there can't be an intersection.