I am trying to estimate when and where 2 objects will collide with non-constant velocites which also have thrust and friction considerations. This for a physics simulation I am working on where I have to collide a missile with another object, given the information that: $$ \vec{V_n} = \vec{V_{n-1}}f+ s/m $$ $$ P_n = P_{n-1} + \vec{V_n} $$ $$ \vec{U_n} = \vec{U_{n-1}}\cdot g $$ $$ Q_n = Q_{n-1} + \vec{U_n} $$ $$ D_n = ||Q_n - P_n|| $$
Solve $D_n = 0$ for $n$
Where:
- $P$ and $Q$ are coordinates for the positions of the two objects
- $\vec{V}$ and $\vec{U}$ are the velocities of the objects
- all vectors are 2-dimensional ($<x,y>$)
- $D_n$ is the distance between $P$ and $Q$ at time n
- $s$ is a thrust value to add to $V$
- $m$ is an object mass
- $f$ and $g$ are friction coefficients
- 0 < $f$ < 1
- 0 < $g$ < 1
- $P_0$, $Q_0$, $\vec{V_0}$, and $\vec{U_0}$ are known
- $s$, $m$, and $f$, $g$ are all supplied constants
- I.e. the only unknown is $n$
Now I have figured out the position functions for $P_n$ and $Q_n$ by simply solving the recurrence relations:
$$Q_n = Q_0 + \frac{g(g^n - 1)}{g - 1}U_0$$
$$P_n = P_0 + \frac{f(f^n - 1)}{f - 1}V_0 + \frac{\lambda f(f^n - 1)}{(f - 1)^2} - \frac{\lambda n}{f - 1}$$
$$\lambda = \frac{s}{m}$$
And I know that a collision will occur when $P_n - Q_n = 0 = D_n$. My problem is that this expression involves 3 unknowns ($f^n$, $g^n$ and $n$) and I would preferably like to not tackle $D_n = 0$ by trial and error. I know that I can approach this problem by an egg drop approach which will reduce the amount of trial and error to at most $log_2(n)$ tries. The thing is that I have been told that this problem can be solved in constant time so I think thre must be a better way to tackle this problem.
I just need to be pushed on the right track (ie technique concept) about how this would be solved in a more direct sense.
3D case
$Q_n$ appears to belong to the line $(Q_0, \vec{U}_0)$ for all $n$. $P_n$ belongs to the plane $(P_0, \vec{V}_0, \vec{s})$ (is $s$ a constant vector ?). If they collide, this is in the intersection (if it exists, and unless the line belongs to the plane). Your formulae then give you $n$ to reach this point for each object, if they are equal then there is collision. You have to treat the case when the line is in the plane separately (2D case).
2D case
Find $n$ such that $P_n \in (Q_0, \vec U_0)$. Then find $m$ such that $Q_m=P_n$. If $m=n$ then there is collision.