1
$\begingroup$

Backstory:

  • We are shooting a cannon from a moving platform (e.g., a ship). Platform velocity is $p$.
  • We know where our target is in relation to us (vector $t$)
  • We know the velocity of our shell ($|s|$)
  • We are in possession of ballistics tables that for a given gun angle and shell velocity specify how far the shell is supposed to reach (and we are very quick in searching them so we have a function $f$ that returns angle $\alpha$ such as to hit a certain distance, assuming certain shell speed)
  • The shell is relatively slow-moving so the platform velocity significantly affects aim, we cannot ignore it
  • We assume the target stays still
  • We want to find out where to aim our cannon so that we hit the target

Variables:

  • $s$ - initial vector for shell
  • $p$ - platform vector for the platform that the shell is launched from ($p_y=0$)
  • $t$ - vector to target ($t_y=0$, as we assume both are on the ground)
  • $r$ - resulting vector for shell ($r = p+s$)

All vectors are 3D unless otherwise stated.

We are given:

  • $|s|$ - initial shell velocity
  • $p$ - platform vector
  • $t$ - vector to target
  • Function $f(|r|, d) = \alpha$ which for a given initial vector magnitude $|r|$ and distance $d$ we want to hit returns the angle $\alpha$ that hits the target

What we want to find:

  • $s$ - initial shell vector

Other notes:

  • Projection of $r$ onto the $xz$ plane is colinear with t (the resulting vector has to go in the direction of the target for us to hit it)

P.S. Seems simple enough, and I have been trying to solve this for a while, mainly by trying to reduce it to a 2D task by projecting it onto the plane where $r$ and $t$ vectors both lie but my vector math/geometry is too rusty.

$\endgroup$
  • $\begingroup$ Since you are not assuming parabolic motion for the projectile, do you not also require a look-up function that gives the time-of-flight for a given shell velocity and elevation angle? $\endgroup$ – DJohnM Mar 11 '13 at 15:52
  • $\begingroup$ You can assume that there is such a function, if it helps any. I thought for this task it is not needed, but I will introduce something like that as soon as I start predicting target position in order to lead targets. Yes, I am not assuming parabolic motion because I plan to obtain the ballistics tables using the physics engine, simulating both air resistance and gravity. I don't want to convert this into a more complex problem by introducing parametric equations for shell motion, because a) I will be using the physics engine anyway and b) I thought it would make things even more complex. $\endgroup$ – John M Mar 11 '13 at 16:12
  • $\begingroup$ This problem can be converted to the frame of reference of the platform, with a moving target, so you are already "lead(ing) targets". $\endgroup$ – DJohnM Mar 11 '13 at 16:53
  • $\begingroup$ I think whether I'm shooting forward or backwards compared to platform direction changes air resistance, which is quadratic to speed. So if I convert the problem like that I think I will lose some precision. $\endgroup$ – John M Mar 11 '13 at 20:06
0
$\begingroup$

As long as $f$ is a black box, I guess you'll have to optimize this iteratively:

  1. Compute $d$ from $t$
  2. Start with a reasonable guess for $\alpha$
  3. Compute $s$ from $\lvert s\rvert$ and $\alpha$, using the heading from $t$
  4. Compute $r$ from $s$ (and $p$)
  5. Compute $\alpha$ from $r$ and $d$
  6. Use the change in $\alpha$ for next iteration, starting at step 3

It might be that you can directly feed the computed $\alpha$ back into the loop. But at least for some functions $f$ that fixpoint iteration might diverge, and you might have to use e.g. bisection to actually locate the best value of $\alpha$.

If you have more details on $f$, you can improve things. If you can differentiate $f$, then you can do some optimization techniques based on gradient descent.

$\endgroup$

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.