寻找碰撞点(移动圆圈+时间)

发布于 2024-12-05 04:58:12 字数 770 浏览 2 评论 0原文

对于两个线性移动的圆,很容易计算碰撞时间: http://twobitcoder.blogspot.com/2010/04/circle-collision-detection.html

这假设圆有固定的起点和固定的移动路径,并且计算碰撞的时间。

是否可以反过来做:

圆1:起点X1,Y1速度VX1,VY1(固定起点,固定直线运动路径),半径R1 圆2:起点X2,Y2速度标量(1m/sec等)(固定起点,固定速度,未知方向),半径R2

是否可以在最短行程时间内确定两个圆的碰撞位置?

IE 圆 1 从 0,0 开始,以速度 1,0 移动(每次向右移动 1 个单位) 圆圈 2 从 5,5 开始,每次可以移动 1 个单位 为了使 2 个圆在最短时间 T 发生碰撞,碰撞位置是什么(或者 VX2、VY2 圆 2 需要移入)。 两个圆的半径都是 1

在这个例子中,解决方案是在圆 1 周围的某个地方,即时间 3 的点 3,0。这个问题感觉相当复杂,因为您有未知的变量:碰撞点、碰撞时间、VX2、VY2。尽管VX2和VY2会受到|VX1|+|VX2|的约束= 1.

问题的原因是告诉圆 2 它应该移动到哪里才能“抓住”圆 1。

强力解决方案是在每个时间间隔检查圆 1 的位置,并计算圆 2 是否如果被告知移动到该点,则会与圆 1 发生碰撞 - 但您可能会错过快速移动的圆的碰撞点,或者获得次优点等。

For two circles moving linearly, it's easy enough to calculate the time of the collision: http://twobitcoder.blogspot.com/2010/04/circle-collision-detection.html

This assumes that the circles have fixed starting points, and fixed movement paths, and calculates the time of the collision.

Is it possible to do it the other way around:

Circle 1: Starting point X1,Y1 velocity VX1,VY1 (fixed starting point, fixed linear movement path), radius R1
Circle 2: Starting point X2,Y2 velocity scalar (1m/sec, etc) (fixed starting point, fixed speed, unknown direction), radius R2

Is it possible to determine the collision position of the two circles for a minimum travel time?

I.E.
Circle 1 starts at 0,0 and moves at speed 1,0 (1 unit to the right per time)
Circle 2 starts at 5,5 and can move 1 unit per time
What would the collision position be (or the VX2,VY2 circle 2 would need to move in) in order for the 2 circles to collide at the lowest time T.
Radius of both circles is 1

In this example, a solution would be somewhere around Circle 1 being at point 3,0 at time 3. The question feels fairly complex as you have unknown variables: collision point, collision time, VX2, VY2. Although VX2 and VY2 would be constrained by |VX1|+|VX2| = 1.

The reason for the question is to tell circle 2 where it should move to in order to 'catch' circle 1.

The brute force solution would be to check the position of circle 1 at every time interval, and calculate if circle 2 would collide with circle 1 if told to move to that point - but you could miss collision points of the circles were moving fast, or get a sub-optimal point, etc.

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

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

发布评论

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

评论(1

伴我心暖 2024-12-12 04:58:12

简单地解决这个问题有两个关键:

  • 首先,在 t 时间内从 x2 可到达的点形成一个以 x2 为中心的圆。
  • 其次,圆接触的第一时刻必须是相切接触的。

这些结合起来告诉我们,点 x2(0)x2(T)、接触点和 x1(T) 都是共线的。

如果我们画一个图来显示这一点,我们就会得到 t 中的一个二次方程:

|| x2(0) - x1(0) - v1 t ||^2 = (r1+r2+t)^2

可以很容易地求解 t。

要获得 v2 的方向,我们只需使用 x1(T)-x2(0) 方向的单位向量。

There are two keys to solving this simply:

  • Firstly the points reachable from x2 in time t form a circle centered on x2.
  • Secondly the first moment that the circles can touch they must be touching tangentially.

These combine to tell us that the points x2(0), x2(T), the contact point and x1(T) are all colinear.

If we draw a diagram showing this we get a single quadratic equation in t:

|| x2(0) - x1(0) - v1 t ||^2 = (r1+r2+t)^2

Which can easily be solved for t.

To get the direction for v2 we just need to use the unit vector in the direction x1(T)-x2(0).

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