Computes the attraction force between two things.
Value for gravity will depend on what range is used for mass. It's probably a good idea
to keep mass to mean something relative - ie 1 is 'full' mass, and adjust the gravity
value until it behaves as you like. Keeping mass in 0..1 range makes it easier to apply to
visual properties later.
// 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));
gravity will have to be tweaked to taste.
distanceRange clamps the computed distance. This affects how tightly the particles will orbit and can also determine speed. By default it is 0.001-0.7
computeAttractionForce(attractor, attractee, gravity, distanceRange?): Point
Computes the attraction force between two things. Value for
gravity
will depend on what range is used formass
. It's probably a good idea to keep mass to mean something relative - ie 1 is 'full' mass, and adjust thegravity
value until it behaves as you like. Keeping mass in 0..1 range makes it easier to apply to visual properties later.Example: Attractee and attractor, gravity 0.005
Example: Many attractees for one attractor, gravity 0.005
Example: Everything mutually attracted
attractor
thing attracting (eg, earth)attractee
thing being attracted (eg. satellite)gravity
will have to be tweaked to taste.distanceRange
clamps the computed distance. This affects how tightly the particles will orbit and can also determine speed. By default it is 0.001-0.7