// DIBUJO DE UN PENDULO [copiado] #include <GL/glut.h> #include <math.h> const double pi2 = 6.28318530718; void display(void){ static double radius = 0.05; const double delta_theta = pi2/20; double xcenter , ycenter; double x, y; double theta = 0.0; double current_angle = cos(omega * time); glColor3f(0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); /* Dibujar la cuerda del péndulo */ glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINES); glVertex2f(0.0, 0.0); xcenter = -cord_length * sin(current_angle); ycenter = -cord_length * cos(current_angle); glVertex2f(xcenter, ycenter); glEnd(); /* Dibujar el disco del péndulo */ glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON); while (theta <= pi2) { x = xcenter + radius * sin(theta); y = ycenter + radius * cos(theta); glVertex2f(x, y); theta += delta_theta; }; glEnd(); glutSwapBuffers(); };