animation.
#include
#include
#include
#include
#include
#include
#include
animation.
#include
#include
#include
#include
#include
#include
#include
bool rotate1=false, rotate2=false;
double t; double dt=0.1;
double angle1=0; double dangle1 =20;
double angle2=0; double dangle2 =20;
double R=5;//radius spiral
double T=20;//time interval
double shiftx,shifty,shiftz;
bool origin=true;
void output_Text(float x, float y, char *text)
{ int len, i;
glColor3f(1, 0, 0); //red text
glRasterPos3f(x, y, 0);
len = (int)strlen(text);
for (i = 0; i < len; i++) { glutBitmapCharacter(GLUT_BITMAP_8_BY_13, text[i]); }
}
void Time_Delay(int dur) {
clock_t start_time;
start_time = clock();
while ((clock() - start_time) < dur) {
}
}
float ax[3]={25,0,0}; float ay[3]={0,25,0}; float az[3]={0,0,25};//axes void plot_Arrow(float
v1[3], float v2[3]) //plot arrow
{
glBegin(GL_LINES);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
}
void plot_Vector(float v[3]) //plot vector
{
float zero[3]={0,0,0};
plot_Arrow(zero,v);
}
void plot_Axis()
{
glColor3f(0,0,0);
plot_Vector(ax);
plot_Vector(ay);
plot_Vector(az);
}
void Draw_Trajectory() {
//your code
}
void myInit3d(void)
{
glClearColor(1,1,1,0);
glColor3f(1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); // clear the screen
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // reset the Current Modelview Matrix
bool rotate1=false, rotate2=false;
double t; double dt=0.1;
double angle1=0; double dangle1 =20;
double angle2=0; double dangle2 =20;
double R=5;//radius spiral
double T=20;//time interval
double shiftx,shifty,shiftz;
bool origin=true;
void output_Text(float x, float y, char *text)
{ int len, i;
glColor3f(1, 0, 0); //red text
glRasterPos3f(x, y, 0);
len = (int)strlen(text);
for (i = 0; i < len; i++) { glutBitmapCharacter(GLUT_BITMAP_8_BY_13, text[i]); }
}
void Time_Delay(int dur) {
clock_t start_time;
start_time = clock();
while ((clock() - start_time) < dur) {
}
}
float ax[3]={25,0,0}; float ay[3]={0,25,0}; float az[3]={0,0,25};//axes void plot_Arrow(float
v1[3], float v2[3]) //plot arrow
{
glBegin(GL_LINES);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
}
void plot_Vector(float v[3]) //plot vector
{
float zero[3]={0,0,0};
plot_Arrow(zero,v);
}
void plot_Axis()
{
glColor3f(0,0,0);
plot_Vector(ax);
plot_Vector(ay);
plot_Vector(az);
}
void Draw_Trajectory() {
//your code
}
void myInit3d(void)
{
glClearColor(1,1,1,0);
glColor3f(1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); // clear the screen
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // reset the Current Modelview Matrix
//the coordinate system, the window and glLookAt in your assigment //can be different
glMatrixMode(GL_MODELVIEW); // position and aim the camera glLoadIdentity();
gluPerspective(45, 1.33, .01, 1000);
gluLookAt(30.0, 30.0, 30.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); }
void myDisplay(void) {
//your code
}
void Do_Nothing(void)
{}
void myMouse(int button, int state, int x, int y) //press left/right button
{ switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
if.