# Artillery Simulation [duplicate]

I need some help on a simulation of an Artillery like this one

I cant figure out how to make the "tomato" to get to the selected spot.

Where can I get solutions for this kind of questions in the future? Physics programming books? I am using LibGDX (Java).

I bought 'Physics for Game Developers' and I liked it. It even has an 'Artillery'-example in it. One with canons.

As far as I remember it was in C but you can easily rewrite it into Java.

If you do not want to buy books. You can ask questions here on Stack Exchange or you can look into GameDev.net.

I cannot see your link at work, but an artillery trajectory is mostly subject to gravity.

Horizontal speed vh is assumed to be constant while in air and the initial location is x0:

x(t) = vh . t + x0


Vertical coordinate accelerate with gravity g, so the second derivative is -g:

y"(t) = -g


You know the initial vertical speed vv, so you can set the constant after integrating:

y'(t) = -g . t + vv


You add the initial location (y0) after integrating again:

y(t) = -0.5 . g^2 t + vv . t + y0


Now you have x and y, the horizontal and vertical coordinates in function of the time t. g is roughly 9.81, it is the constant for the gravitation formula