2

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?

2 Answers2

1

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.

  • You don't need a quartic, but a quadratic equation. This can be seen both mathematically (see my solution above) as well as physically. – wltrup Sep 03 '15 at 14:24
  • @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? – Tito Piezas III Sep 03 '15 at 14:41
  • Yes, I was the one who downvoted your answer because it does not correctly address the OP's question (calculate the 3-component V⃗ , which is the gun barrel vector needed to hit a target moving at a constant velocity). Moreover, an answer that might technically be correct (and I'm not completely sure it is) but is overly complicated and obscures the natural simplicity of the problem does not qualify for a good-quality answer. I'm sure you understand that it's nothing personal. – wltrup Sep 03 '15 at 14:59
  • On my point about your answer being overly complicated and obscure, consider these, as examples: it's not clear from your solution whether it's possible to solve this problem in a space with more dimensions but the straightforward solution I provided shows that the problem is solvable by a quadratic in any number of dimensions. Also, your solution carries the acceleration of gravity around when, in fact, gravity plays no role whatsoever in the solution. Also, if one were to implement your solution in, say, a simulation, one would have to solve a quartic when, in fact, there is no need to do so – wltrup Sep 03 '15 at 15:06
  • @wltrup: As I said, my answer is purely based on his system. But that's your opinion, and your entitled to it. Anyway, I've got other posts to look at... – Tito Piezas III Sep 03 '15 at 15:11
  • Well, the OP's system is the wrong approach to the problem. – wltrup Sep 03 '15 at 15:15
  • I don't get 3 from your equation. I get: $$t^2 - t\frac{F_y - V_y + \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g} - t\frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g} + \frac{(F_y - V_y)^2 + (V_y - F_y)^2 - 2g(P_y - \beta_y)}{g^2} = 0$$ Where did I go wrong? – Jonathan Mee Sep 03 '15 at 15:48
  • @JonathanMee: It is of form $$t^2-t(a+\sqrt{x})-t(a-\sqrt{x})+c = 0$$ Those square roots are of $opposite$ signs and cancel out. Are you doing this by hand, or by computer software? :) – Tito Piezas III Sep 03 '15 at 15:52
  • Totally by hand :D Note that the square roots do cancel in the last term but multiplying two roots together should give you 4 terms the middle two terms do not cancel. If for example we let: $$a = \frac{F_y - V_y + \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}$$ and $$b = \frac{F_y - V_y - \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}$$ then your original equation looks like: $$(t - a)(t - b)$$ with should simplify to: $$t^2 - ta - tb + ab$$ If you substitute back in $a$ and $b$ you'll get my equation above. – Jonathan Mee Sep 03 '15 at 16:00
  • 1
    @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? – Tito Piezas III Sep 03 '15 at 16:04
  • OK, I'm closer. With your explanation I can get to: $$t^2 - 2t\frac{F_y - V_y}{g} + \frac{2(F_y - V_y)^2 - 2g(P_y - \beta_y)}{g^2} = 0$$ But that's still not the same. – Jonathan Mee Sep 03 '15 at 16:15
  • @JonathanMee Out of curiosity, why are you wasting your time and energy trying to solve the problem in a complicated way when the solution is so much simpler ? Also, if you're planning to use the solution in some simulation (a game or something of the like), solving a quartic will be slower, less accurate, and really unnecessary. – wltrup Sep 03 '15 at 16:19
  • 1
    @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. – Tito Piezas III Sep 03 '15 at 16:21
  • 1
    @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.) – Tito Piezas III Sep 03 '15 at 16:26
  • @wltrup Frankly I'm on more of a fact finding mission currently. And I'd like to understand the way to solve via this system of equations. I don't believe that you are correct when you say that solving the quartic will be less accurate, though I do suspect it will be slower. But to know that I need to be able to get it into a simplified form, which will probably simplify out to something more complicated than your answer. – Jonathan Mee Sep 03 '15 at 19:06
  • @JonathanMee I don't understand. What facts are you looking for? At the end of your qs, you say "Is there any other way to solve this?" because you're clearly frustrated by the approach you chose. The answer I gave you is the simplest, most straight-forward approach to a standard problem in physics. You say you want to understand how to solve this using your approach. Ok, fair enough, but then you need to make sure your approach is correct to begin with. TBH, I'm suspicious of your 3rd eq. You appear to be using a form of $v_2^2 = v_1^2 + 2,a,\Delta s$ but – wltrup Sep 03 '15 at 19:46
  • @JonathanMee I don't think you're using it correctly. As for accuracy, from a numerical analysis POV, any time you have to perform extra computations you're incurring on accumulating floating point truncation errors so, yes, solving a quartic when you could just solve a quadratic is less accurate. Moreover, the final answer for both the time of flight and the bullet velocity components does not depend on the acceleration of gravity. Thus, – wltrup Sep 03 '15 at 19:47
  • @JonathanMee whatever calculations you end up doing with a complicated solution must end up cancelling all the appearances of $g$. Again, from a num analysis POV, that's terribly inaccurate. – wltrup Sep 03 '15 at 19:48
  • Wow, I'd never used WolframAlpha like that. That's really powerful! Is there like a tutorial to figure out how to use it? Thanks, by the way, after re-crunching I can get the quartic! Now I just need to sort out @wltrup's option... – Jonathan Mee Sep 03 '15 at 19:49
  • @wltrup My third equation is just a standard rate fall equation to account for the acceleration of gravity: $$\frac{gt^2}{2} + (V_y - F_y)t + P_y = \beta_y$$ Plugged into the quadratic equation that's $$t = \frac{F_y - V_y \pm \sqrt{(V_y - F_y)^2 - 2g(P_y - \beta_y)}}{g}$$ But I don't need the plus term cause I'm only interested in hitting on the downward slope of the parabola. – Jonathan Mee Sep 03 '15 at 20:02
  • @JonathanMee Where did you get those two equations from? The $y$-position of the target, as a function of time, is: $$\beta_y(t) = \beta_y(0) + F_y,t - \frac{1}{2},gt^2$$ and the $y$-position of the bullet, as a function of time, is $$y(t) = P_y + V_y,t - \frac{1}{2},gt^2$$ I see no way to obtain your "standard rate fall equation" from the above two. Also, what quadratic equation are you referring to? I maintain that I believe your problem setup is incorrect so all the work that you and Tito have done is incorrect. Once again, this is a standard problem in Physics. – wltrup Sep 03 '15 at 20:24
  • @JonathanMee I see what you mean by quadratic eq now. You mean to solve for $t$ in your standard rate fall eq. The problem is that your standard rate fall eq is incorrect and here's an intuitive way to see that it's incorrect. Your standard rate fall eq is saying that the target starts with a $y$-position equal to that of the gun and is moving with an initial $y$-velocity of $V_y - F_y$. But think about it: the target doesn't care what velocity the bullet has. The target moves at its own velocity. And, also, it's not necessarily at the same $y$ position as the gun when the gun is fired. – wltrup Sep 03 '15 at 20:43
1

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 $$

wltrup
  • 3,983
  • What was the reason for squaring 1? What does that get you that you did not already have? – Jonathan Mee Sep 04 '15 at 16:44
  • 1
    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. – wltrup Sep 04 '15 at 16:56
  • 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. – wltrup Sep 04 '15 at 17:05
  • 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. – Jonathan Mee Sep 08 '15 at 11:49
  • 1
    @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. – wltrup Sep 08 '15 at 17:12
  • Bah, no worries! Thanks for chiming the vector suggestion that really is a good way of thinking about it. – Jonathan Mee Sep 08 '15 at 17:49