TheCannon

The goal is to calculate where to aim a cannon to be able to hit a target at a specific location.

- The cannon is located at origo (0,0)
- The target is located at ($x_t$, $y_t$)
- The initial cannon ball velocity is given, $v_0$
- The shooting angle, $\alpha$, shall be determined

We assume to shoot in vacum i.e. we have no friction due to air drag. There is only one force applied on the cannon call during flight and that is the gravitational force, $F = mg$.

Using Newtons second law for the movement in y direction we have.

(1)$-m g = m a_y \Leftrightarrow a_y = -g \Leftrightarrow \frac{dv_y}{dt} = -g$

By integrating this formula (twice) we get the following.

(2)$v_y(t) = v_{y0} - g t$

(3)$y(t) = y_0 + v_{y0} t - \frac{g t^2}{2}$

Movement in the x direction is simpler.

(4)$x(t) = x_0 + v_{x0} t$

The cannon speed velocity can be expressed by the shooting angle and the initial cannon ball velocity.

(5)$v_{y0} = v_0 sin(\alpha)$

(6)$v_{x0} = v_0 cos(\alpha)$

If we use the movement equations at the time of impact, $t_t$, we get the following. Note that $x_0$ and $y_0$ is zero.

(7)$y_t = v_{y0} t_t - \frac{g t_t^2}{2}$

(8)$x_t = v_{x0} t_t$

Initial velocities can be expressed in terms of $t_0$ and $\alpha$.

(9)$y_t = v_0 t_t sin(\alpha) - \frac{g t_t^2}{2}$

(10)$x_t = v_0 t_t cos(\alpha)$

From the second equation you can express $\alpha$ as.

(11)$\alpha = acos(\frac{x_t}{v_0 t_t})$

Which in turn gives an equation with a single undetermined contant, $t_t$.

(12)$y_t = v_0 t_t sin(acos(\frac{x_t}{v_0 t_t})) - \frac{g t_t^2}{2}$

This can be solved with … TBD

If $\alpha$ would be known instead of $v_0$ the solution would be simpler.

By replacing $t_t$ from the second equation in the first the $t_t$ will be separated.

(13)$y_t = v_0 \frac{x_t}{v_0 cos(\alpha)} sin(\alpha) - \frac{g t_t^2}{2} \Leftrightarrow y_t = x_t tan(\alpha) - \frac{g t_t^2}{2}$

From this equation $t_t$ can easily be determined.

(14)$t_t = \sqrt{\frac{2}{g} (x_t tan(\alpha) - y_t)}$