/* chaos1.c interesting plots using chaos reather than fractals */ #include "GL/glut.h" #include static float xmin = 0.0; /* minimum value */ static float xmax = 1.0; /* maximum value */ static float x; /* working value */ static float rmin = 2.95; static float rmax = 3.95; static float r; static float dr; /* r step size */ /* heading for plot */ static char head[] = " chaos1 x=r*x*(1.0-x) run 200, plot 300 $ " ; void display(void) { int i, j; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 0.0, 1.0); /* blue */ glBegin(GL_LINES); dr = (rmax-rmin)/200.0; r = rmin ; while(r <= rmax) { x = 0.3; for(i=1; i<=200; i++) { x = r * x * ( 1.0 - x ) ; } for(i=1; i<=300; i++) { x = r * x * ( 1.0 - x ) ; glVertex2f(x, r); glVertex2f(x, r+dr); } r = r + dr ; } glEnd(); glFlush(); } void reshape(int w, int h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D (xmin, xmax, rmin, rmax); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(1.0, 1.0, 1.0, 1.0); } int main(int argc, char* argv[]) { glutInit(&argc,argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow(argv[0]); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; } /* end chaos1 */