/* modify main to create our own world file */ int main() { struct world jello; int i,j,k; double x,y,z; // set the integrator and the physical parameters strcpy (jello.integrator,"RK4"); jello.dt = 0.0001000; jello.n = 5; jello.kElastic = 300; jello.dElastic = 0.50; jello.kCollision = 300; jello.dCollision = 0.25; jello.mass = 1.0 / 512; // set the inclined plane jello.incPlanePresent=0; jello.a =-1; jello.b = 1; jello.c = 1; jello.d = 2; //set the external force field jello.resolution=30; jello.forceField = (struct point *) malloc (jello.resolution*jello.resolution*jello.resolution*sizeof(struct point)); int forceIndex; for (i=0; i<= jello.resolution-1; i++) for (j=0; j<= jello.resolution-1; j++) for (k=0; k<= jello.resolution-1; k++) { // set the force at node i,j,k // actual space location = x,y,z x = -2 + 4*(1.0 * i / (jello.resolution-1)); y = -2 + 4*(1.0 * j / (jello.resolution-1)); z = -2 + 4*(1.0 * k / (jello.resolution-1)); forceIndex = i * jello.resolution * jello.resolution + j * jello.resolution + k; jello.forceField[forceIndex].x = 0; jello.forceField[forceIndex].y = 0; jello.forceField[forceIndex].z = 0; } //set the positions of control points for (i=0; i<=7; i++) for (j=0; j<=7; j++) for (k=0; k<=7; k++) { jello.p[i][j][k].x=(1.0 * i / 7) ; jello.p[i][j][k].y=(1.0 * j / 7) ; jello.p[i][j][k].z=(1.0 * k / 7) ; } //set the velocities of control points for (i=0; i<=7; i++) for (j=0; j<=7; j++) for (k=0; k<=7; k++) { jello.v[i][j][k].x= 10;// * rand() % 100; jello.v[i][j][k].y= 30;// * rand() % 100; jello.v[i][j][k].z= 0; // * rand() % 100; } //write the jello variable out to file on disk writeWorld ("jello.w", &jello); return 0; }
/* modify main to create your own world */ int main() { struct world jello; int i,j,k; double x,y,z; int numConstraintPoints = 11; // set the integrator and the physical parameters // the values below are EXAMPLES, to be modified by you as needed strcpy(jello.integrator,"RK4"); jello.dt=0.0005000; jello.n=1; jello.kElastic=200; jello.dElastic=0.25; jello.kCollision=400.0; jello.dCollision=0.25; jello.mass= 1.0 / 512; // set the inclined plane (not used in this assignment; ignore) jello.incPlanePresent=1; jello.a=-1; jello.b=1; jello.c=1; jello.d=2; // set the external force field jello.resolution=0; jello.forceField = (struct point *)malloc(jello.resolution*jello.resolution*jello.resolution*sizeof(struct point)); for (i=0; i<= jello.resolution-1; i++) for (j=0; j<= jello.resolution-1; j++) for (k=0; k<= jello.resolution-1; k++) { // set the force at node i,j,k // actual space location = x,y,z x = -2 + 4*(1.0 * i / (jello.resolution-1)); y = -2 + 4*(1.0 * j / (jello.resolution-1)); z = -2 + 4*(1.0 * k / (jello.resolution-1)); jello.forceField[i * jello.resolution * jello.resolution + j * jello.resolution + k].x = 0; jello.forceField[i * jello.resolution * jello.resolution + j * jello.resolution + k].y = 0; jello.forceField[i * jello.resolution * jello.resolution + j * jello.resolution + k].z = 0; } // initial position and velocities for a constraint line jello.numConstraintPoints = numConstraintPoints; for (i = 0; i < numConstraintPoints; i++) { jello.pc[i].x = i/(double)numConstraintPoints; jello.pc[i].y = 0; jello.pc[i].z = 0; jello.vc[i].x = 0; jello.vc[i].y = 0; jello.vc[i].z = 0; } /* // set the positions of control points for (i=0; i<=7; i++) for (j=0; j<=7; j++) for (k=0; k<=7; k++) { jello.p[i][j][k].x=1.0 * i / 7; jello.p[i][j][k].y=1.0 * j / 7; jello.p[i][j][k].z=1.0 * k / 7; if ((i==7) && (j==7) && (k==7)) { jello.p[i][j][k].x=1.0 + 1.0 / 7; jello.p[i][j][k].y=1.0 + 1.0 / 7; jello.p[i][j][k].z=1.0 + 1.0 / 7; } } // set the velocities of control points for (i=0; i<=7; i++) for (j=0; j<=7; j++) for (k=0; k<=7; k++) { jello.v[i][j][k].x=10.0; jello.v[i][j][k].y=-10.0; jello.v[i][j][k].z=20.0; } */ // write the jello variable out to file on disk // change jello.w to whatever you need writeWorld("CPS.w",&jello); return 0; }