razorsese

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

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.

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

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.