here is code of my program

g := 9.81
p := 30
kat := p*(Pi/180) (* ok 45 stopni*)

(*    \
y=x*Tan[kat]-g/(2*vXpocz^2)*x^2   *)
 Plot[x*Tan[p * (Pi/180)] - 
   g/(2*(Vstart*Sin[p * (Pi/180)])^2)*x^2, {x, 0, 700}, 
  AxesLabel -> {x [m], h [m]}, PlotLabel -> "Throw trajectory plot",
  PlotRange -> {0, 300}],

 {Vstart, 10, 50}, {p, 30, 60},
 Button["Print", {Print["Max height: ", 
     x*Tan[p * (Pi/180)] - g/(2*(Vstart*Sin[p * (Pi/180)])^2)*x^2, {x,
       0, 700}]],
   Print["Range: ", Vstart^2/g*Sin[2*(p * (Pi/180))]]}

And here is output

enter image description here

I want that my program will gave me height and range after clicking button. It work but range value is't correct. Is there any function that check when there instersection on x axis ?

  • 1
    $\begingroup$ The problem is not the calculation of range, the problem is your plot: Notice the weird behaviour when you vary p- that doesn't seem like a proper inclined throw. You can fix this by replacing Sin with Cos in the argument to plot (the second term should be $-\frac g2 t^2=-\frac g2 \left(\frac x{v_x}\right)^2$ with $v_x=v\cos p$, not $v_x=v\sin p$) $\endgroup$ – Lukas Lang Jan 10 at 17:25
  • $\begingroup$ @LukasLang oh I see now :D thank you $\endgroup$ – marczin Jan 10 at 17:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.