DMOMPCJ2SNZ7SEAVPROANSOHQDGVL2OKD223EC24ZF5GJJ53SYTQC
}
pub fn forces(state: Vec<Body>) -> Vec<V3> {
let mut result = vec![
V3 {
x: 0.,
y: 0.,
z: 0.
};
state.len()
];
for (ix, xb) in state.iter().enumerate() {
for (iy, yb) in state.iter().enumerate() {
if ix != iy {
let d = yb.position - xb.position;
let r2 = d.x * d.x + d.y * d.y + d.z * d.z;
let f = xb.mass * yb.mass / r2;
result[ix] += d.normalize() * f;
}
}
}
for b in result.iter_mut() {
*b *= G;
}
result