/* voronoi.c diagram where each object owns space nearest to it */ /* voronoi < voronoi.dat file input or mouse input */ /* left click to add point to polygon, */ /* right click to end this polygon */ /* expect strange results if polygons overlap */ #include #include #include #include static int num_obj = 0; static int num_pts[8]={0,0,0,0,0,0,0,0}; /* max of 8 objects, add colors */ static float x[20][10]; /* each onject max 10 vertices */ static float y[20][10]; static float x_min=0.0, x_max=40.0; static float y_min=0.0, y_max=40.0; static int width = 400; static int height = 400; static float scale = 10.0; static GLfloat colors[8][3] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.7, 0.7, 0.7, 0.5, 0.5, 0.7}; static GLfloat dx; /* one pixel in drawing coordinates */ static GLfloat dy; /* one pixel in drawing coordinates */ static void read_geom() { int i, j; int pts; x_min = 0.0; y_min = 0.0; x_max = 40.0; y_max = 40.0; printf("enter object data, else zero for using mouse.\n"); scanf("%d", &num_obj); printf("%d objects \n", num_obj); if(num_obj>8) {printf("8 objects max\n"); exit(0);} for(i=0; ix_max) x_max = x[i][j]; if(x[i][j]y_max) y_max = y[i][j]; if(y[i][j]a2x && x>a3x) out = 1; if(xa2y && y>a3y) out = 1; if(y