BallVector decode_balls(double y[]) { BallVector ans = new BallVector(); for (int i = 0; i < num_balls; i++) { Ball p = new Ball(); p.pos.x = y[i * 4 + 1]; p.pos.y = y[i * 4 + 2]; p.speed.x = y[i * 4 + 3]; p.speed.y = y[i * 4 + 4]; ans.addElement(p); } return ans; }
void init_world() { springs = new SpringVector(); // [num_springs]; add_spring(0, 1); add_spring(1, 2); add_spring(2, 0); add_spring(3, 4); add_spring(4, 5); add_spring(5, 3); add_spring(0, 4); balls = new BallVector(); // [num_balls]; for (int i = 0; i < NUM_POINTS; i++) { Ball p = new Ball(); init_rand(p); balls.addElement(p); } }