I have a question here on how to plot trajectories. Currently I have a piece of code that looks something like this. The forum wouldn’t let me use parenthesis for some reason, so I’ll use " to signal curved brackets.
glClear “GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT”;
glPushMatrix"";
int q;
glBegin “GL_POLYGON”;
glColor3f “1.0f,0.0f,0.0f”;
for “q=0; q<12; q++”
glVertex3f “RADIUScos"PI/6q”+15xdes,RADIUSsin"PI/6q"+15ydes,0.0";
glEnd"";
glPopMatrix"";
glutSwapBuffers"";
xdes and ydes are some global variables defining the location of the ball. This piece of code basically draws a circle moving across the screen depending on xdes and ydes, determined by another thread, which changes over time. I got that down ok.
What if I want to also trace the trajectory over time? I suppose I could save xdes and ydes into a massive data array and draw the entire trajectory everytime the screen refreshes. But this could be computationally expensive. Is there a way for me to draw the trajectory as new position data comes along without erasing what it has already drawn? I still want the circle to be shown as moving across the screen, so I guess the screen has to be cleared to a certain extent. Any help would be much appreciated. Thanks.