#include #include #include static dWorldID world; static dBodyID ball; int main(int argc, char** argv) { FILE *fp; int i; const dReal *pos; dMass temp_mass; float step_size = 0.1; fp = fopen("output.txt", "w"); /* Create a world and set gravity */ world = dWorldCreate(); dWorldSetGravity(world, 0.0, -9.80665, 0.0); /* Create a ball in the world */ ball = dBodyCreate(world); dBodySetPosition(ball, 0.0, 0.0, 0.0); dMassSetSphere(&temp_mass, 1.0, 0.5); dBodySetMass(ball, &temp_mass); /* Write out the y-coordinate for the position of the ball*/ /* over the first 10 timesteps (0.1 seconds each timestep). */ for (i = 0; i <= 10; i++) { pos = dBodyGetPosition(ball); fprintf(fp, "%f\n", pos[1]); dWorldStep(world, step_size); } dWorldDestroy(world); dCloseODE(); fclose(fp); }