2
$\begingroup$

I need to calculate the 3-component $\vec V$, which is the gun barrel vector needed to hit a target moving at a constant velocity. To find this information I'll also need to find $t$ which is the time of flight of a munition.

This system of 4 equations should be enough to solve for those 4 unknowns, however when simplified I get a quintic polynomial.

$$\begin{cases} t = \frac{\beta_x - P_x}{V_x - F_x}\\ t = \frac{\beta_z - P_z}{V_z - F_z}\\ t = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\\ \|\vec V\| = \sqrt{V_x^2 + V_y^2 + V_z^2}\\ \end{cases}$$

Where the following are given:

  • $\vec \beta$ is the current target position
  • $\vec P$ is the gun position
  • $\vec F$ is the velocity of the target
  • $g$ is the acceleration due to gravity
  • $\|\vec V\|$ is the magnitude of $\vec V$

Is there some method of substitution where I can find a set of possible solutions for $\vec V$?

This may not be tremendously helpful but just to demonstrate the most promising substitution I've tried, I attempted to plug the 1st and 2nd equations into the 4th equation and got this:

$$\begin{cases} t = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\\ \|\vec V\|^2 = \frac{(\beta_x - P_x - F_xt)^2}{t^2} + \frac{(\beta_z - P_z - F_zt)^2}{t^2} + V_y^2\\ \end{cases}$$

When the $t$ is removed from the denominators and the squared parenthetical terms resolved:

$$\begin{cases} t = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\\ t^2(\|\vec V\|^2 - V_y^2) = \beta_x^2 - 2P_x\beta_x + P_x^2 - 2\beta_xF_xt + 2P_xF_xt + F_x^2t^2 + \beta_z^2 - 2P_z\beta_z + P_z^2 - 2\beta_zF_zt + 2P_zF_zt + F_z^2t^2\\ \end{cases}$$

Extracting the $t$ terms gives us:

$$\begin{cases} t = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\\ 0 = t^2(F_x^2 + F_z^2 - \|\vec V\|^2 + V_y^2) + t(2P_xF_x - 2\beta_xF_x + 2P_zF_z - 2\beta_zF_z) +\beta_x^2 + \beta_z^2 - 2\beta_xP_x - 2\beta_zP_z\\ \end{cases}$$

Using the Quadratic Equation we can finally solve for $t$:

$$\begin{cases} t = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\\ t = \frac{2\beta_xF_x - 2P_xF_x + 2\beta_zF_z - 2P_zF_z \pm \sqrt{(2P_xF_x - 2\beta_xF_x + 2P_zF_z - 2\beta_zF_z)^2 - 4(F_x^2 + F_z^2 - \|\vec V\|^2 + V_y^2)(\beta_x^2 + \beta_z^2 - sP_x\beta_x - 2P_z\beta_z)}}{2(F_x^2 + F_z^2 - \|\vec V\|^2 + V_y^2)}\\ \end{cases}$$

At this point the equations can be set equal, but even if we could somehow remove the square roots by squaring, that would result in a $V_y^4$ in the denominator with at least a $V_y$ in the numerator that would be cross multiplied against, and apparently we can't solve quintic equations.

So, I need something else. Is there any other way to solve this?

$\endgroup$
1
$\begingroup$

I originally understood the problem as if the target is also falling, so I'm going to solve the problem in two different scenarios. The first is my original solution, when the target is also falling instead of moving at constant velocity. The second scenario is when the target has some means of propulsion that keeps its velocity constant.

I'm going to use a more intuitive and common notation to solve the problem. First, define a coordinate system whose origin is at the barrel's exit point.

Falling target

The equations of motion for the target and the munition (I'll call it a bullet from now on), in vector notation, are: $$ \mathbf{r}_T(t) = \mathbf{r}_T(0) + \mathbf{v}_T(0)\,t + \frac{1}{2}\,\mathbf{g}\,t^2 $$ and $$ \mathbf{r}_B(t) = \mathbf{v}_B\,t + \frac{1}{2}\,\mathbf{g}\,t^2 $$ where $\mathbf{r}_T(0)$ is the vector position of the target, with respect to the barrel's exit point, at the time of firing ($t=0$), $\mathbf{v}_T(0)$ is the velocity of the target at the time of firing, $\mathbf{v}_B$ is the initial velocity of the bullet, and $\mathbf{g}$ is the acceleration of gravity. Note that the vector position of the bullet at the time of firing is the origin, as expected.

The condition for the bullet to hit the target is simply that their position vectors are the same at some moment in time $t > 0$, that is, $$ \mathbf{r}_B(t) = \mathbf{r}_T(t) $$

Thus, you need to solve $$ \mathbf{r}_T(0) + \mathbf{v}_T(0)\,t = \mathbf{v}_B\,t $$ whose solution, since $t > 0$, is

$$ \mathbf{v}_B = \mathbf{v}_T(0) + \frac{\mathbf{r}_T(0)}{t} \qquad(1) $$

To find $t$, we now use the fact that $|\mathbf{v}_B|$ is known. Squaring (1), we find $$ v_B^2 = v_T^2 + \frac{r_0^2}{t^2} + \frac{2\,\mathbf{v}_T(0)\cdot\mathbf{r}_T(0)}{t} $$

where $\cdot$ represents the dot product of the two vectors involved, $v_T$ is a shorthand for $|\mathbf{v}_T(0)|$, and $r_0$ is a shorthand for $|\mathbf{r}_T(0)|$. This can be rewritten as

$$ (v_B^2 - v_T^2)\,t^2 - 2\,\mathbf{v}_T(0)\cdot\mathbf{r}_T(0)\,t - r_0^2 = 0 \qquad(2) $$

This is a quadratic equation on $t$ and may have 0, 1, or 2 real solutions. You're looking for a positive real solution, since you want $t>0$, if a real solution exists at all. If there are 2 real solutions, both positive, then you want the smallest solution.

Once a positive solution to (2) is found, you can plug that result back into (1) and obtain the components of the bullet velocity. Note that the acceleration of gravity does not appear anywhere in the solution, and that's expected since gravity affects both the target and the bullet in identical ways.

You can tell how many real solutions there will be by examining the sign of the discriminant $\Delta$ of the quadratic equation:

$$ \frac{\Delta}{4} \equiv \left(\,\mathbf{v}_T(0)\cdot\mathbf{r}_T(0)\,\right)^2 + (v_B^2 - v_T^2)\,r_0^2 $$

If $\Delta < 0$ then there are no real solutions. If $\Delta = 0$, there is only one real solution, and if $\Delta > 0$ there are 2 real solutions. Assuming that $\Delta \ge 0$, the solution(s) is(are):

$$ t = \frac{2\,\mathbf{v}_T(0)\cdot\mathbf{r}_T(0) \pm \sqrt{\Delta}}{2\,(v_B^2 - v_T^2)} = \frac{\mathbf{v}_T(0)\cdot\mathbf{r}_T(0) \pm \sqrt{\frac{\Delta}{4}}}{(v_B^2 - v_T^2)} $$

Target moving at constant velocity

The equations of motion for the target and the bullet, in vector notation, are: $$ \mathbf{r}_T(t) = \mathbf{r}_T(0) + \mathbf{v}_T\,t $$ and $$ \mathbf{r}_B(t) = \mathbf{v}_B\,t + \frac{1}{2}\,\mathbf{g}\,t^2 $$ where $\mathbf{r}_T(0)$ is the vector position of the target, with respect to the barrel's exit point, at the time of firing ($t=0$), $\mathbf{v}_T$ is the (constant) velocity of the target, $\mathbf{v}_B$ is the initial velocity of the bullet, and $\mathbf{g}$ is the acceleration of gravity. Note that the vector position of the bullet at the time of firing is the origin, as expected.

The condition for the bullet to hit the target is simply that their position vectors are the same at some moment in time $t > 0$, that is, $$ \mathbf{r}_B(t) = \mathbf{r}_T(t) $$

Thus, you need to solve $$ \mathbf{r}_T(0) + \mathbf{v}_T\,t = \mathbf{v}_B\,t + \frac{1}{2}\,\mathbf{g}\,t^2 $$ which we can write as $$ \mathbf{v}_B\,t = \mathbf{r}_T(0) + \mathbf{v}_T\,t - \frac{1}{2}\,\mathbf{g}\,t^2 \qquad(1) $$

To find $t$, we now use the fact that $|\mathbf{v}_B|$ is known. Squaring (1), we find $$ v_B^2\,t^2 = r_0^2 + v_T^2\,t^2 + \frac{1}{4}\,g^2t^4 + 2\,\mathbf{r}_T(0)\cdot\mathbf{v}_T\,t - \mathbf{r}_T(0)\cdot\mathbf{g}\,t^2 - \mathbf{v}_T\cdot\mathbf{g}\,t^3 $$ or, after simplifying,

$$ \frac{1}{4}\,g^2t^4 - \left(\mathbf{v}_T\cdot\mathbf{g}\right)t^3 + \left(v_T^2 - v_B^2 - \mathbf{r}_T(0)\cdot\mathbf{g} \right)t^2 + 2\left(\mathbf{r}_T(0)\cdot\mathbf{v}_T\right)t + r_0^2 = 0 $$

where $\cdot$ represents the dot product of the two vectors involved and $r_0$ is a shorthand for $|\mathbf{r}_T(0)|$.

This is a quartic equation for $t$ and, once again, you're looking for the smallest positive real solution, if a solution exists at all. Once such a solution is found, then plugging it into

$$ \mathbf{v}_B = \frac{\mathbf{r}_T(0)}{t} + \mathbf{v}_T - \frac{1}{2}\,\mathbf{g}\,t $$

(which is obtained from (1) by dividing by $t$) will give the components of the bullet velocity.

A note about $\mathbf{r}_T(0)$

$\mathbf{r}_T(0)$ is the position of the target relative to the barrel's exit point, at the time of firing the weapon. If the size of the weapon can be ignored then this is simply the vector position of the target at the time of firing minus the vector position of the weapon (at the time of firing), relative to whatever coordinate system you have.

A note about the dot product:

The dot product of two vectors $\mathbf{a}$ and $\mathbf{b}$ is a real number (not a vector) given by $$ \mathbf{a} \cdot \mathbf{b} = a_xb_x + a_yb_y + a_zb_z $$

$\endgroup$
  • $\begingroup$ What was the reason for squaring 1? What does that get you that you did not already have? $\endgroup$ – Jonathan Mee Sep 4 '15 at 16:44
  • 1
    $\begingroup$ It gets rid of the components of $\mathbf{v}_B$ and gives us its magnitude squared, which is a known quantity. See, the beauty of squaring is that it quickly leads to the equation for $t$ and all the components are then put aside until the equation just above the "A note about $\mathbf{r}_T(0)$". No messing around with components. $\endgroup$ – wltrup Sep 4 '15 at 16:56
  • $\begingroup$ No messing around with the components of $\mathbf{v}_B$, I should say. Of course, the various dot products will be computed by using the components of the vectors involved but, even then, that's all very clean and easy. $\endgroup$ – wltrup Sep 4 '15 at 17:05
  • $\begingroup$ This answer it produces the exact same equations as those obtained from the system of equations that @TitoPiezasIII solved into a quartic. His equations are not "slower, less accurate, and really unnecessary." So, while I feel obligated to accept this as the representation that is easiest on the eyes, I feel Tito Piezas III's answer was unfairly down-voted, and as such I would be grateful to see the down-vote removed. $\endgroup$ – Jonathan Mee Sep 8 '15 at 11:49
  • 1
    $\begingroup$ @JonathanMee That's quite fair and I'll undo my down-vote. The reason for my comments regarding Tito's answer was that back when I made them, I had misinterpreted the question, as I mentioned before. My apologies to both you and Tito. $\endgroup$ – wltrup Sep 8 '15 at 17:12
1
$\begingroup$

Based on your system, you only need a quartic equation, so your unknowns $t, V_x, V_y, V_z$ have an analytic solution.

For simplicity, I will continued what you have achieved so far namely,

$$t = \tfrac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\tag1$$

$$|\vec V\|^2 = \frac{(\beta_x - P_x - F_xt)^2}{t^2} + \frac{(\beta_z - P_z - F_zt)^2}{t^2} + V_y^2\tag2$$

Express $(1)$ as a quadratic in $t$,

$$\Big(t-\tfrac{F_y - V_y \color{red}- \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\Big) \Big(t-\tfrac{F_y - V_y \color{red}+ \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}\Big) = 0$$

and I get the simpler,

$$gt^2+2(V_y-F_y)t+2(P_y-\beta_y) = 0\tag3$$

Solve for $V_y$,

$$V_y = \frac{2(\beta_y-P_y+F_yt)-gt^2}{2t}$$

Substitute into $(2)$

$$|\vec V\|^2 = \frac{(\beta_x - P_x - F_xt)^2}{t^2} + \frac{(\beta_z - P_z - F_zt)^2}{t^2} + \frac{\big(2(\beta_y-P_y+F_yt)-gt^2\big)^2}{(2t)^2}\tag4$$

and one can see $(4)$ is just a quartic in $t$ that can solve your system of equations. Once you have $t$, then you can recover $V_x, V_y, V_z$.

P.S.1 Since you are using a particular sign, $\color{red}-\sqrt{x}$, in your system, then not all of the four roots may be valid solutions.

P.S.2 For a simple way to solve quartics, see this post.

$\endgroup$
  • $\begingroup$ You don't need a quartic, but a quadratic equation. This can be seen both mathematically (see my solution above) as well as physically. $\endgroup$ – wltrup Sep 3 '15 at 14:24
  • $\begingroup$ @wltrup: Based purely on the OP's system, it resolves to a quartic. If there is a way to have another system that resolves to quadratic, then well and good. But were you the one who down-voted? $\endgroup$ – Tito Piezas III Sep 3 '15 at 14:41
  • 1
    $\begingroup$ @JonathanMee: Omg by hand? :) Anyway, you get, $$t^2-t(a+b)+ab = 0$$ Notice anything when you add $a+b$ as you defined them? $\endgroup$ – Tito Piezas III Sep 3 '15 at 16:04
  • 1
    $\begingroup$ @JonathanMee: Or solve $(3)$ for $t$ and you'll see its two roots are $a$ and $b$. If you are now satisfied, solve $(3)$ for $V_y$, plug it into $(2)$, and you will get $(4)$. Inspecting its coefficients, one can see that your system will yield only a quartic. $\endgroup$ – Tito Piezas III Sep 3 '15 at 16:21
  • 1
    $\begingroup$ @JonathanMee: You are doing it $by\, hand$, and it is prone to error. I'm using Mathematica. Here's some WolframAlpha output. (Take note I removed subscripts and used lower-case letters, but you should be able to recognize your variables. Then look at the expanded form at the bottom.) $\endgroup$ – Tito Piezas III Sep 3 '15 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.