I am introducing uniform circular motion into my continuous collision detection system.
Given a point moving in uniform circular motion $P =(d \cos (v_a t), d \sin(v_a t))$, I want to find the time of collision with a circle moving in a straight line $C = (x_1 + v_x t, y_1 + v_y t)$.
I tried to plug this information into the distance formula and to get the values of t that would equate the distance with the radius of the circle but it's not really working out.
$$(d \cos (v_a t) - x_1 - v_x t)^2 + (d \sin(v_a t) - y_1 - v_y t)^2 = r^2$$
I was unable to get a solution using Wolfram and I don't have enough knowledge in the subject to really go further given than I can't find anything on Google.
If there's no way to find the appropriate value for $t$ (which should be the first positive one if there's more), then I'd like suggestions on how I could proceed in finding an appropriate way to approximate it or a different approach.
I'll also need to probably do something similar for a point and a segment instead of a circle next.
Introduction
Given two points in the plane:
$$ P\left(x_P + d\,\cos(\varphi_0 + \omega\,t),\,y_P + d\,\sin(\varphi_0 + \omega\,t)\right), \quad \quad \quad C\left(x_C + v_x\,t,\,y_C + v_y\,t\right) $$
with $d > 0$, by the Pythagorean theorem they are at a distance $r > 0$ when:
$$ \left(x_C + v_x\,t - x_P - d\,\cos(\varphi_0 + \omega\,t)\right)^2 + \left(y_C + v_y\,t - y_P - d\,\sin(\varphi_0 + \omega\,t)\right)^2 = r^2\,. $$
We are interested in calculating the smallest $t \ge 0$ that verifies this equation.
Numerical solve with graphic inspection
By developing the squares and grouping, we have:
$$ a\,t^2 + b\,t + c = \left(x_0 + v_x\,t\right)\cos(\varphi_0 + \omega\,t) + \left(y_0 + v_y\,t\right)\sin(\varphi_0 + \omega\,t) $$
i.e.
$$ \begin{cases} y_1 = a\,t^2 + b\,t + c \\ y_2 = \left(x_0 + v_x\,t\right)\cos(\varphi_0 + \omega\,t) + \left(y_0 + v_y\,t\right)\sin(\varphi_0 + \omega\,t) \\ y_1 = y_2 \end{cases} $$
where the parameters have been defined:
$$ \small x_0 \equiv x_C - x_P\,, \quad y_0 \equiv y_C - y_P\,, \quad a \equiv \frac{v_x^2 + v_y^2}{2\,d}\,, \quad b \equiv \frac{x_0\,v_x + y_0\,v_y}{d}\,, \quad c \equiv \frac{x_0^2 + y_0^2 + d^2 - r^2}{2\,d}\,. $$
In particular, assuming:
$$ x_P = y_P = \varphi_0 = 0\,, \quad x_C = y_C = \omega = 1\,, \quad v_x = v_y = -1\,, \quad d = 3\,, \quad r = 2.5 $$
graphically it's equivalent to identifying the following intersections:
where a numerical approximation of $t = \beta$ can be easily calculated by the Newton-Raphson method. It's clear that in order to automate this method, graphic inspection must be eliminated.
A possible numerical automation
Defined the function $f : \mathbb{R} \to \mathbb{R}$ of law:
$$ f(t) := \left(x_C + v_x\,t - x_P - d\,\cos(\varphi_0 + \omega\,t)\right)^2 + \left(y_C + v_y\,t - y_P - d\,\sin(\varphi_0 + \omega\,t)\right)^2 - r^2 $$
and defined the following temporal parameters respectively:
$$ t_i = 0\,, \quad \quad \quad t_f = \delta t\,, \quad \quad \quad t_{\max} = T $$
while:
$$ f(t_i) \cdot f(t_f) > \epsilon \quad \quad \land \quad \quad t_f < t_{\max} $$
with $\epsilon > 0$ a fixed tolerance, we calculate:
$$ t_i = t_f\,, \quad \quad \quad t_f = t_f + \delta t\,. $$
If $f$ has at least one zero for $0 \le t < T$, a closed and limited interval $\left[t_i,\,t_f\right]$ will be identified.
Since $f$ is continuous in this interval and such that $f(t_i) \cdot f(t_f) < \epsilon$, the Bolzano's theorem ensures the existence of at least one zero and if $\delta t$ is small enough this zero is also unique!
This done, calculated the midpoint of this interval:
$$ t_0 = \frac{t_i + t_f}{2} $$
according to the Newton-Raphson method, while:
$$ \left|\frac{f(t_0)}{f'(t_0)}\right| > \epsilon $$
we calculate:
$$ t_0 = t_0 - \frac{f(t_0)}{f'(t_0)} $$
which according to the previous numerical example gives $t_0 \approx 0.642034$.
It's clear that the greatest difficulty is in identifying the parameters $0 < \delta t < T$, which will be defined on the basis of a careful analysis and after many numerical tests based on one's own numerical needs. If there were more efficient strategies, I am ready to take notes. ^_^