Circle A is moving right along the x axis. Circle B is moving up along the y axis. I would like to know if they are going to collide. (not when, just if.)
Radii are same, different constant velocities.
This answer seems to address the issue and my question should better have been a followup to that. (Apologies for not having enough reputation to comment.)
I can't seem to solve for t (time) the provided equation (the circles will collide if t exists):
(Oax + t*Dax - Obx - t*Dbx)^2 + (Oay + t*Day - Oby - t*Dby)^2 = (ra + rb)^2
Here again in readable terms:
(CircleA.initialPosition.x + t*CircleA.velocity.x -
CircleB.initialPosition.x - t*CircleB.velocity.x)^2
+
(CircleA.initialPosition.y + t*CircleA.velocity.y -
CircleB.initialPosition.y - t*CircleB.velocity.y)^2
=
(CircleA.radius + CircleB.radius)^2
Which in my case is a little simpler since the circles are moving along the axes (velocity is 0 on one axis) and the radii are same:
(CircleA.initialPosition.x + t*CircleA.velocity.x -
CircleB.initialPosition.x)^2
+
(CircleA.initialPosition.y - CircleB.initialPosition.y -
t*CircleB.velocity.y)^2
=
(2*radius)^2
Still I can't solve it, and the provided link to the auto-solver doesn't help my thick head either.
(In particular I don't get
sqrt(-(D4 - D3)^2)
The expression inside sqrt() is always negative, so it always fails. What am I missing?)
Auto-solver aside, I hope someone could show the way to solve the equation for t (and maybe a moderator could combine the questions, sorry for the trouble).
Or, any other way to tackle the issue, maybe using a built-in box2d feature I am not aware of.