碰撞点:圆碰撞 [英] Point of impact: circle collision

查看:98
本文介绍了碰撞点:圆碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个关于robocup的学校项目,其中机器人正在用AI踢足球.一切正常后,我仍然会遇到一些麻烦.

I'm doing a school project about robocup where robots are playing football with AI. As everything works fine I am still stuck with something.

机器人是从顶视图绘制的简单球体.不允许两个玩家进入对方,并且应该在撞击点获得新的更新位置.

The robots are simple spheres drawn from top view. Both player shouldn't be allowed to walk into each other and should get a new updated position on the point of impact.

因为碰撞处理程序只是检查它们是否发生碰撞..我希望是否有一种方法可以检测圆在哪里发生碰撞.因此,我可以将碰撞球体的位置更新为最后一个已知的非碰撞位置,以使它们不会相互穿过并可能反弹.

As the collision handler just checks if they collide or not.. I was hoping if there was a way to detect where the circles collide. So I can update the position of the colliding sphere to the last known non-colliding position so they can't walk trough each other and maybe bounce off.

推荐答案

您需要做的是找到两个圆之间的交点,该交点可以是两个点,一个点或一个都没有.这基本上是通过一起求解两个圆的方程来完成的.这是数学:

What you will need to do is to find the point of intersection between the two circles, which could be two points, one point, or none. This is basically done by solving the equations of the two circles together. Here's the math:

http://www.analyzemath.com/CircleEq/circle_intersection.html

因为这是上学,所以我将编码留给您:)

Since this is for school I'll leave the coding to you :)

这篇关于碰撞点:圆碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆