Function attractionForce

For a given set of attractors, returns a function that a sets acceleration of attractee. Keep note though that this bakes-in the values of the attractor, it won't reflect changes to their state. For dynamic attractors, it might be easier to use computeAttractionForce.

const f = Forces.attractionForce(sun, gravity);
earth = Forces.apply(earth, f);
// Create a force with all things as attractors.
const f = Forces.attractionForce(things, gravity);
// Apply force to all things.
// The function returned by attractionForce will automatically ignore self-attraction
things = things.map(a => Forces.apply(a, f));