View Full Version : Projectile motion

02-12-2012, 07:46 AM
Need some help whit the following code:

void quadratic(int angle,int vel)

float theta=3.14*angle/180;//angle to radians
ux=vel*cos(theta);//X coord init value
uy=vel*sin(theta);//Y coord init value

t=((vel*vel)*(2*(sin(theta)*cos(theta))))/9.8;//maximum range that projectile can reach

for(i=1;i<=t;i++)//nr of projectile (i=time) (t=distance to travel)

x=ux*i;//X coord value
y=uy*i+(0.5*(-9.8)*(i*i));//Y coord value



I'm trying to make a projectile motion just like that in pocket tank but i cant get it done.
For example its show a number of points but they don't follow a quadratic trajectory and the points don't stick whit equal distance between them.

The Little Body
02-12-2012, 11:52 AM

Here is a Wikipédia french link that speak about parabolic motion of a projectile http://fr.wikipedia.org/wiki/Trajectoire_parabolique

I think that the 9.8 constant is the gravity ?

02-13-2012, 05:20 AM
Thanks for the link.I will try to look and I hope to fix it