Wiki2
TheCannon

The cannon

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 tx_t, y ty_t)
  • The initial cannon ball velocity is given, v 0v_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=mgF = mg.

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

(1)mg=ma ya y=gdv ydt=g -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 y0gt v_y(t) = v_{y0} - g t
(3)y(t)=y 0+v y0tgt 22 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 x0t 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 0sin(α) v_{y0} = v_0 sin(\alpha)
(6)v x0=v 0cos(α) v_{x0} = v_0 cos(\alpha)

If we use the movement equations at the time of impact, t tt_t, we get the following. Note that x 0x_0 and y 0y_0 is zero.

(7)y t=v y0t tgt t 22 y_t = v_{y0} t_t - \frac{g t_t^2}{2}
(8)x t=v x0t t x_t = v_{x0} t_t

Initial velocities can be expressed in terms of t 0t_0 and α\alpha.

(9)y t=v 0t tsin(α)gt t 22 y_t = v_0 t_t sin(\alpha) - \frac{g t_t^2}{2}
(10)x t=v 0t tcos(α) x_t = v_0 t_t cos(\alpha)

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

(11)α=acos(x tv 0t t) \alpha = acos(\frac{x_t}{v_0 t_t})

Which in turn gives an equation with a single undetermined contant, t tt_t.

(12)y t=v 0t tsin(acos(x tv 0t t))gt t 22 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 0v_0 the solution would be simpler.

By replacing t tt_t from the second equation in the first the t tt_t will be separated.

(13)y t=v 0x tv 0cos(α)sin(α)gt t 22y t=x ttan(α)gt t 22 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 tt_t can easily be determined.

(14)t t=2g(x ttan(α)y t) t_t = \sqrt{\frac{2}{g} (x_t tan(\alpha) - y_t)}