Detect correct ball that will be hit first

37 Views Asked by At

Suppose there are some static balls of radius $r$ in a $2D$ table. I will put one of them (let's call it $b$) with velocity $v$.

My question is: how to detect which ball will be hit first? I couldn't prove to myself my approach works and I'm pretty sure it doesn't.

  • My thought: get all balls whose distance to the line formed by $b$ and $v$ is less than $r$. The answer would be the ball among those whose distance to $b$ is the minimum.

enter image description here

In the image, the nearest ball will be touch but the furthest ball will be touched first.

How can I correctly guess which will be chosen first?

2

There are 2 best solutions below

0
On BEST ANSWER

Draw boundaries with radius $2r$ around static balls. When center of moving ball reaches boundary, collision occurs.

enter image description here

0
On

Here's an insight: when two circles just touch, they are tangent. That means, right at the point when the moving ball hits another ball, you can draw a straight line through their centres of length exactly the sum of their radii.

This lets you adjust the "effective" distance of the balls depending on how far off the movement axis of the moving ball it is.

Concretely, for balls of equal radii $r$, WOLOG rotate the basis so that say $b=\vec{0}$ and $v$ is in the x-direction. Then a ball at position $(x,y)$ will be hit when the moving ball reaches $\left(x-\sqrt{4r^2-y^2},0\right)$