Projectile Motion

Started by
0 comments, last by dpadam450 12 years, 2 months ago
I'm having a hard time solving this problem

Untitled.png

It suppose to create a quadratic motion(like that in Worms or Pocket Tank) and the space between the points should be equal
but i cant manage to get it right.

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*2;i++)//nr of projectile (i=time) (t=distance to travel)
{
x=ux*i;//X coord value
y=uy+(i*i*-9.8*0.5);//Y coord value
glVertex2f(x/50,y/50);
}
}

void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-20.0f, 0.0f, -50.0f);
glPushMatrix();
glBegin(GL_POINTS);
quadratic(45,15);
glEnd();
glPopMatrix();

glutSwapBuffers();
}
Advertisement
Not sure what you are asking, and why/what space should be equal?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement