public NBodySystem() { bodies = new Body[] {Body.sun(), Body.jupiter(), Body.saturn(), Body.uranus(), Body.neptune()}; double px = 0.0; double py = 0.0; double pz = 0.0; for (int i = 0; i < bodies.length; ++i) { px += bodies[i].vx * bodies[i].mass; py += bodies[i].vy * bodies[i].mass; pz += bodies[i].vz * bodies[i].mass; } bodies[0].offsetMomentum(px, py, pz); }