
function R=f(Y)
    mu=0.05
    m=45
    g=9.8
    R=[Y(3);Y(4);-(mu/m)*sqrt(Y(3)^2+Y(4)^2)*Y(3);-g/m-(mu/m)*sqrt(Y(3)^2+Y(4)^2)*Y(4)]
endfunction

function yy=RK2(f,theta,dt)
    Y=[0;0;950*cos(theta);950*sin(theta)]
    yy=[Y]
    t=0
    while Y(2) >= 0
        Y=Y+dt*f(Y+(dt/2)*f(Y))
        yy=[yy,Y]
        t=t+dt
    end
endfunction

function angle=cible(d)
    theta = 0
    dis=0
    while abs(dis-d) > 100
        T=RK2(f,theta,0.1)
        dis=T(1,$)
        //disp([dis,theta])
        theta=theta+0.01
    end
    angle=theta-0.01
endfunction
