I am currently programming a simulation for a pinball game and want to calculate the time when the ball hits a circle (if they collide at some point). For the calculation part, i'm adding the radius of the ball to the radius of the circle, so that i only have to check if the midpoint of the ball collides with the circle. Of course, the circle is displayed with it's original radius.
Now for the ball's (midpoint) trajectory i've got these two equations who define the movement of the ball on the x- and y-axis (depending on the gravitational acceleration):
$x\left(t\right) = S.x + V.x*t$
$y\left(t\right) = S.y + V.y * t - \frac{1}{2}G * t^2$
With $S$= starting point of the ball, $V$= initial velocity, $G$= gravitational acceleration and $t$= time.
To check for collision, i took these two equations and put them into the equation of a circle, namely:
$(x - M.x)^2 + (y - M.y)^2 = r^2$
With $M$ and $r$ = midpoint and radius.
And what i got is:
$((S.x + V.x * t)-M.x)^2 + ((S.y + V.y*t-\frac{1}{2}G*t^2)-M.y)^2 = r^2$
I actually multiplied out that monster of an equation completely, only to recognize that i don't know what to do with it now. I ended up with an equation that looks like this (i better not type in my whole solution):
$ at^4 + bt^3 + ct^2 + dt + e = 0$
So i need to get the zeros of that polynomial and i don't know how. Obviously the coefficients could be any integer or decimal number and i haven't found a method to deal with that kind of equation yet.
Thanks for any kind of help and maybe someone can think of another way to solve that problem than getting the zeros of that 4th degree polynomial.
I'm sorry for any grammar mistakes.
Edit: I know i could just check for the distance between the circle and the ball every timestep, but that's not what i want. Because of performance issues it is way much better to calculate the time, when the first collision occurs, only once.