PDA

View Full Version : Projectile motion

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

{

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

glVertex2f(x/50,y/50);
}

}

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, 12:52 PM
Hi,

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 ?

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