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.
// Create a force with all things as attractors. constf = 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));
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
.Example: Force
Example: Everything mutually attracted