static void printGeom (PrintingContext &c, dxGeom *g) { unsigned long category = dGeomGetCategoryBits (g); if (category != (unsigned long)(~0)) { c.printIndent(); fprintf (c.file,"category_bits = %lu\n",category); } unsigned long collide = dGeomGetCollideBits (g); if (collide != (unsigned long)(~0)) { c.printIndent(); fprintf (c.file,"collide_bits = %lu\n",collide); } if (!dGeomIsEnabled (g)) { c.print ("disabled",1); } switch (g->type) { case dSphereClass: printSphere (c,g); break; case dBoxClass: printBox (c,g); break; case dCapsuleClass: printCapsule (c,g); break; case dCylinderClass: printCylinder (c,g); break; case dPlaneClass: printPlane (c,g); break; case dRayClass: printRay (c,g); break; case dConvexClass: printConvex (c,g); break; case dTriMeshClass: printTriMesh (c,g); break; case dHeightfieldClass: printHeightfieldClass (c,g); break; } }
void* animatePlane(void* arg) { while (ymin != -20000) { printShooter(startshooter,endshooter); printTurret(startturret,endturret); printPlane(start,end); //printf("%d %d\n", startturret, endturret); int dx = abs(ix2 - ix1); int sx = (ix1 < ix2) ? bulletSpeed : -bulletSpeed; int dy = abs(iy2 - iy1); int sy = (iy1 < iy2) ? bulletSpeed : -bulletSpeed; int err = (dx > dy ? dx : -dy)/2; int e2; if (drawLine) { if ((ly1 < 0) || (ly1 > 600) || (lx1 < 0) || (lx1 > 800) || (ly2 < 0) || (ly2 > 600) || (lx2 < 0) || (lx2 > 800)) { drawLine = 0; } else { drawLineFunc(ly1, lx1, ly2, lx2); } e2 = err; if (e2 > -dx) { err -= dy; lx1 += sx; lx2 += sx; } if (e2 < dy) { err += dx; ly1 += sy; ly2 += sy; } } usleep(15000); clearScreen(); if (right == 1 ){ start += 3; end += 3; if (end == 600){ right = 0; left = 1; } } else if (left == 1){ start -= 3; end -= 3; if (start == 100){ right = 1; left = 0; } } } }
void printFacet(const zhull_t * const zh, const facet_t * const f) { list_t indices=emptyList(); indices=findValueListInList(f->neighbors,zh->facets); printf("plane: "); printPlane(f->plane); printf("\n"); printf("corners: "); printList(f->corners); printf("outsideset: "); printList(f->outsideset); printf("insideset: "); printList(f->insideset); printf("neighbors: "); printList(indices); freeList(&indices); printf("pt %lu with maxdist %5.2f\n", (unsigned long)(f->farthest_outside_point), f->maxdistance); }
// int totalDistance(RST* root); // Must check for errors in instance, if so output error to console. // If option output is given, output file to a text // If option output is not given output to screen int main(int argc, char** argv){ char* filename = NULL; char** lines; Plane plane; char* options = NULL; bool correctFile = true; int** MST = NULL; int* degrees; //initiallize rand() with current time srand(time(NULL)); // Cheching for arguments, if they are greater than or equal to two, assume // their are options and a filename being passed in trying to be passed in. if(argc >= 2){ filename = getFilename(argv, argc); options = getOption(argv, argc); } // Grab Data if (filename == NULL){ plane = getParameters(); plane.instance_size = plane.NUM_PT; } else { lines = readFile(filename); // Check to see if a file was succesffully parsed if(lines == NULL){ printf("File not found\n"); printf("Exiting...\n"); return -1; } plane.generation = getGeneration(filename); plane = getFileParameters(lines); correctFile = checkFile(plane); free(lines); } // Ensure instances is of the correct size; if(!correctFile){ printf("File is corrupt, the instance file does not match specification\n"); return -2; } if(filename != NULL){ // If we opened up a file, the Plane instance is all ready generated for us. printPlane(plane, filename, options); if(plane.instance_size > 1){ MST = prims(plane); printMST(MST,plane.instance_size, filename, options); degrees = nodeDegree(MST, plane.instance_size-1); } else { printf("Can not generate MST, insufficient nodes \n"); } } else { while(plane.generation < plane.total_gen){ // If not we need to generate instances for the number of planes required plane.instance = genInstance(plane.NUM_PT, plane.MAX_X, plane.MAX_Y); printPlane(plane, NULL, options); filename = genFilename(plane.NUM_PT, plane.generation); if(plane.instance_size > 1){ MST = prims(plane); printMST(MST,plane.instance_size, filename, options); degrees = nodeDegree(MST, plane.instance_size-1); } else { printf("Can not generate MST, insufficient nodes \n"); } plane.generation++; } } RST* root; int rootIndex = findRoot(MST, plane.instance_size-1); printf("Root index %i\n", rootIndex); root = buildNode(NULL, rootIndex, NULL, 0, 0 ); buildTree(root, plane.instance, MST, plane.instance_size-1); // Need to create code to free plane.instance and and sub arrays of instance printList(root,0); //printf("Overlap is %i\n", maxOverlap(root)); //printf("Distance is %i\n", totalDistance(root)); freeMST(MST, plane.instance_size-1); freePlane(&plane); freeRST(root); // need to free MST return 0; }