I am making a Javascript program that includes physics but the projectile formula is very difficult for me to get right. I saw a link with the formula https://math.stackexchange.com/questions/82934/how-to-find-the-parabola-of-a-flying-object?newreg=e730be6696794b3f9ef8404df475c9c8 but this is quite hard to visualize with the way javascript does math functions. My code is the following.
//speed
var speed = 0;
//angle
var angle = 0;
//previous coord log
var pballx = 0;
var pbally = 0;
//ball fall counters
var bffasttime = 0;
var bftime = bffasttime/60;
//log counter
var lftime = 0;
var ltime = 0;
speed = sqrt(sq(abs(bally-pbally))+sq(abs(ballx-bally)))/0.2;
angle = Math.atan((pbally-bally)-(pballx-ballx))*180/Math.PI;
bally = ballx*Math.tan(angle)-[(1/2)*(9.8/sq(bftime))*sq(bftime)]/sq(speed);
It allows you to drag a ball around and every .2 seconds it is dragged it logs the coords which is what pbally and pballx and when released it calculates angle speed and the parabola but instead it just teleports to the top. I'm almost positive my formulas are correct but if they aren't any correction would be nice. Thanks!!!