enter image description here

So, I'm making a game. The game has archer in it. Arrows are simulated in 2D, $(x,y)$

An archer acquires a target and needs to know at what angle he needs to tilt his bow for the arrow to land at the target.


$t =$ time
$a =$ angle

The following constants are known:

$V_{0} =$ velocity, the initial velocity of the projectile.
$H =$ the initial height of the archer
$G =$ Gravity
$L =$ the distance to the target
$F =$ A simplified air friction constant.
$V$ (velocity) $=$ $V_{0} - F t$

I'm looking for $a$, the angle of the bow.

I know that $V_{x} = \cos(a)$ and $V_{y} = \sin(a)$

I know that: $V_{x} \cdot t - 0.5 \cdot F \cdot t^{2} = L$

I know that: $t = \frac{V_{y} + \sqrt{V_{y}^{2} + 2 \cdot G H}}{G}$

Which gives me these functions:

public static double length(double height, double angle, double velocity) {
    double vz = Math.sin(angle*2*Math.PI)*velocity;
    double v = Math.cos(angle*2*Math.PI)*velocity;
    double t = getTime(height, vz);
    return getLength(v, t);
public static double getTime(double height, double vz) {
    return (vz + Math.sqrt(vz*vz + 2*G*height))/G;
public static double getLength(double v, double time) {
    return time*v - 0.5*FRICTION*time*time;

This allows me for testing angles, and they work. In fact, my only solution right now is to test for the correct angle by binary search. It usually get a solution with 10-15 iterations.

There are many solutions for this without air friction, but I'm looking for one with it included.

However, I can't manage to substitute t and solve for $a$.

  • $\begingroup$ Wiki is your friend: en.wikipedia.org/wiki/… $\endgroup$
    – Gert
    Commented Feb 7, 2022 at 10:56
  • $\begingroup$ Does not answer the question. It does not have a solution for an angle with air friction. It has some reasoning with air friction, but this is advanced friction, while I am fine to simplify mine to a constant $\endgroup$
    – Jake
    Commented Feb 7, 2022 at 12:22

1 Answer 1


Starting with :

$$m\,\ddot x=-F\\ m\,\ddot y=-m\,g$$

and $$x(0)=0~,\dot x(0)=v\,\cos(\alpha)\\ y(0)=h~,\dot y(0)=v\,\sin(\alpha)$$

you obtain the solutions

$$x(t)=-\frac 12\,{\frac {F{t}^{2}}{m}}+v\cos \left( \alpha \right) t\tag 1$$ $$y(t)=-\frac 12\,g{t}^{2}+v\sin \left( \alpha \right) t+h\tag 2$$

with $~x(t)=L~$ you obtain the time $~t_L~$ that the projectile reach the distance L. substitute this time in equation (2)
$$y(t=t_L) =0=f(\alpha)$$ from the solution $~f(\alpha)=0~$ you obtain $~\alpha~$

$$f(\alpha)=-\frac 12\,{\frac {g \left( v\cos \left( \alpha \right) m-\sqrt {{v}^{2} \left( \cos \left( \alpha \right) \right) ^{2}{m}^{2}-2\,FLm} \right) ^{2}}{{F}^{2}}}+{\frac {v\sin \left( \alpha \right) \left( v \cos \left( \alpha \right) m-\sqrt {{v}^{2} \left( \cos \left( \alpha \right) \right) ^{2}{m}^{2}-2\,FLm} \right) }{F}}+h $$


the start velocity $~v~$ must be greater then $ ~{\frac {\sqrt {2}\sqrt {F\,L\,m}}{m}}~$ otherwise you don't obtain real solution for the angle


numerical solution $~f(\alpha)=0~$with Newton method



Data=[F= 0.1,L=20,m=1,g=10,v=15,h=2]

$$n=0,\alpha_1=0+\frac{f(0)}{f'(0)}=0.346~,f(\alpha_1)=-0.888\\\\ n=1~,\alpha_2=0.404~,f(\alpha_2)=-0.02\\ n=2~,\alpha_3=0.406~,f(\alpha_3)=-0.00001$$

so you need 2 interation to obtain the solution

  • $\begingroup$ Thank you Eli. Forgive my ignorance, but I need to solve this for α. I.E α =equation of other stuff, so α must be factored out and put on the left hand side. I tried doing this with wolframalpha and it couldn't do it. $\endgroup$
    – Jake
    Commented Feb 7, 2022 at 14:51
  • 1
    $\begingroup$ The analytical solution is not useful because you have more then one solution , instead put all the data und solve for $\alpha$ I use Maple fsolve $\endgroup$
    – Eli
    Commented Feb 7, 2022 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.