I'm trying to develop a simulation in C#, and I have to find the intersection (or collision) point of two moving circles, in 2D space.
Actually one of my circles will be stationary, so only one of them will be moving (linearly, i.e. constant velocity)
So I have two circles with radii R1 and R2, and center points P1 and P2, and the point P1 is changing with constant velocity V1, so I need a way to determine at which point will they collide, also to check if they will collide at all.
Thanks for any help !
Edit :
For the checking (if they will collide) part, I think we can do it by simply calculating the shortest distance between the first circle's velocity line, and the second circle's center, and checking if the distance is greater than R1+R2, so the only thing remains is to find the collision point.
So the question is :
I am assuming the circles will collide, and I need an expression for the collision point P, in terms of P1, P2, R1, R2 and V1.
Based on your edited question, I assume you have computed the distance between $P_2$ and the nearest point on the path of $P_1$ (the point of closest approach). Let $d_1$ denote that distance. I assume you have determined that $d_1 < R_1 + R_2.$ I also assume you have coordinates for $P_2$ and $P_1(0),$ where $P_1(0)$ denotes the initial position of $P_1.$
Let $d_0$ denote the distance between $P_1(0)$ and $P_2.$ Let $A$ be the closest point of approach and let $s_A$ denote the distance from $P_1(0)$ to $A.$ The triangle with vertices $P_1(0),$ $A,$ and $P_2$ is a right triangle, and $s_A$ can be found by the Pythagorean Theorem:
$$ s_A = \sqrt{d_0^2 - d_1^2}.$$
Let $B$ be the location of $P_1$ at the moment of collision and let $s_{AB}$ be the distance between $A$ and $B.$ The distance between $P_2$ and $B$ is $R_1 + R_2,$ and $\triangle BAP_2$ is a right triangle. Then (again using the Pythagorean Theorem)
$$ s_{AB} = \sqrt{(R_1 + R_2)^2 - d_1^2}.$$
The distance from $P_1(0)$ to $B$ is $s_B = s_A - s_{AB},$ so now you merely need to construct a vector in the same direction as $V_1$ with length $s_B$ --that is, compute the vector $\dfrac{s_B}{\|V_1\|} V_1$-- and add that vector's coordinates to the coordinates of $P_1(0).$ This gives you the coordinates of $B.$
But you wanted the point $P$ where the circles touch. If $W$ is the vector from $P_2$ to $B,$ then $\dfrac{R_2}{R_1 + R_2} W$ is the vector from $P_2$ to $P,$ so you just need to add the coordinates of $\dfrac{R_2}{R_1 + R_2} W$ to the coordinates of $P_2,$ and the result is the coordinates of the point you want.