# Shooting tangent to a moving circle [closed]

I have a circle shaped object which has; center point C(X1,Y1), radius R, moving with speed of S1 and angle B. Now I want to throw a particle from origin (0,0) with speed of S2 and with an angle of A so the particle would touch (be tangent to) circle not from it's front (where the circle moves towards) but from it's back. All parameters except A are known and constant through movement. How may I find A (what angle to throw particle)?

## closed as unclear what you're asking by eranreches, Magdiragdag, José Carlos Santos, GNUSupporter 8964民主女神 地下教會, hardmathDec 22 '17 at 3:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• What if circle is moving directly towards origin? Will it be bad if the particle first touches the front and then the back, or should these cases be discarded? – arseniiv Dec 17 '17 at 21:51
• I get the feeling your "circle shaped object" is rotating (you say "moving" and mention an "angle"), but the description of motion is not clear enough. I'm guessing the crux of your problem is to "throw" a particle leading the moving object so that they arrive at a common point at the same time, but the data seems hard to piece together. – hardmath Dec 22 '17 at 3:38

## 1 Answer

I'd think of this in terms of two unknowns: the angle $A$ and the time $t$ at which the contact is to occur. With these you can compute the point of contact as $$P=S_2\cdot t\cdot(\cos A,\sin A)$$ and the position of the center at that time as $$Q=(X_1,Y_1)+S_1\cdot t\cdot(\cos B,\sin B)\;.$$ Now you need to express two conditions: one that the distance between these is $R$, which you can write e.g. using the scalar product $\langle\cdot,\cdot\rangle$ as $$\langle P-Q,P-Q\rangle=R^2\tag1$$ and another to ensure that the tangent line is perpendicular to the radius, i.e. $$\langle P,P-Q\rangle=0\;.\tag2$$

At this point you have two equations in two unknowns. But these equations are non-linear, they even contain trigonometric functions. You could use the tangent half-angle formula to turn $\sin A$ and $\cos A$ into rational functions, and then multiply the equation with the denominator to obtain a polynomial equation. Then you can eliminate $t$ using standard elimination techniques like the resultant. Once you have a bunch of algebraic solutions, you need to check which of them are in front of the movement and which behind.

With $\cos A=\frac{1-u^2}{1+u^2}$ and $\sin A=\frac{2u}{1+u^2}$ I can eliminate $u$ using a resultant and then factor that resultant to obtain different sufficient conditions. Several of the conditions represent non-degeneracy constraints: $S_2=0$ and $t=0$ (since a null vector solved (2) even if it originates in $t=0$ or $S_2=0$; you could remove those factors there if you wanted). There is also one term quadratic in $t$ which only allows complex solutions (negative discriminant). And finally there is one relevant quadratic equation in $t$:

$$(S_1^2 - S_2^2)t^2 + (2S_1(X_1\cos B + Y_1\sin B))t + (X_1^2 + Y_1^2 - R^2) =0\;.\tag3$$

Solve this and you find at which times $t$ you can obtain a solution. You may want to ignore negative values of $t$ as these represent times in the past. Then you can compute the two associated points of tangency (essentially a circle-circle intersection), and of these pick the one which is “from it's back” in terms of the direction of movement. Note that there might be situations (with the movement directed almost towards or away from the origin) where both or neither of the points of tangency could be considered “back”.

I have created an interactive demonstration of this problem, which you can use to explore some of the scenarios.

Historical detail: Originally I had used the resultant to eliminate $t$ in order to more directly read the angle off the solutions. Only when creating my demonstration did I realize that for every point $t$ there would be two tangents, usually one “front” and one “back”. At this point I realized that solving for $t$ first would likely make things easier. The relevant conditions in terms of $u$ are

\begin{align*} (S_1(X_1\sin B-(Y_1+R)\cos B)-S_2(Y_1+R))&\,u^2 + \\ 2(-X_1S_2+RS_1\sin B)&\,u\phantom{^1} + \tag4 \\ (S_1(X_1\sin B-(Y_1-R)\cos B)+S_2(Y_1-R))&\,\phantom{u^0}=0 \\[4ex] (S_1(X_1\sin B-(Y_1-R)\cos B)-S_2(Y_1-R))&\,u^2 + \\ 2(-X_1S_2-RS_1\sin B)&\,u\phantom{^1} + \tag5 \\ (S_1(X_1\sin B-(Y_1+R)\cos B)+S_2(Y_1+R))&\,\phantom{u^0}=0 \end{align*}

Note that there might be situations where the coefficient of the quadratic term becomes zero, making the whole equation linear instead. In these situations, the usual formula for solving a quadratic equation would entail a division by zero. This is an indication that $u=\infty$ is a solution, along with the solution from the remaining linear equation. It corresponds to $A=\pi$. The correct framework here is the real projective line, where division by zero is well defined. One could express the whole quadratic equation in a homogeneous fashion, but I fear that would be going too far here.

If either of the quadratic equations (4) or (5) is satisfied, then there exists a $t$ such that both the equations (1) and (2) are satisfied simultaneously. Which means you have up to 4 solutions to consider, two from each quadratic equation. I consider it likely that these fall into pairs for many situations: two from the past ($t<0$) and two from the future, as well as two tangent from the front and two from the back. But this is not always the case, and the interactive demonstration can help you explore corner cases.

• I found total of 4 A with this formulas but that didn't pass tangent. I couldn't find where did i make a mistake. – Moguzya Dec 27 '17 at 19:07
• Works for me, see gagern.github.io/CindyJS/se/math/2017/12/28/… for an illustration. (Seeing that I believe there should be a more elegant solution, computing first $t$ and then $A$.) But please be more specific as to why you's day this doesn't work, preferably giving a counterexample. – MvG Dec 28 '17 at 15:33