Commit Graph

28 Commits

Author SHA1 Message Date
Mike Bostock
cf287b8dba Fix exact coincidence with d3.forceCollide. 2016-04-29 09:33:17 -07:00
Mike Bostock
eca9a02f2f Increase the default alphaMin. 2016-04-27 16:35:41 -07:00
Mike Bostock
19e2a7a7e0 Reduce default drag. 2016-04-27 11:20:10 -07:00
Mike Bostock
2f7cd4ae93 Rename simulation.start to simulation.restart.
This is more consistent with timer.restart, and more appropriate given that the
simulation now starts automatically.
2016-04-27 09:52:44 -07:00
Mike Bostock
831ad55a59 Fix #20 - simulation.tick now returns boolean.
This changes simulation.tick to always advance the simulation one step,
regardless of the current value of alpha and alphaMin. If alpha is less than
alphaMin after this step, simulation.tick returns true, indicating that the
simulation can be safely ended.

Furthermore, simulation.tick no longer dispatches a tick event; the tick event
is only dispatched by the simulation’s internal timer. This is now consistent
with simulation.stop, which likewise does not dispatch an end event; the end
event is only dispatched when the simulation’s internal timer stops.
2016-04-27 09:17:47 -07:00
Mike Bostock
aa410cf32e Deterministic initialization!
Rather than initialize the node positions randomly, use a phyllotaxis. This is
just as good, and means the resulting behavior will be deterministic as long as
no nodes are exactly coincident.
2016-04-26 17:37:00 -07:00
Mike Bostock
e88cd9e8c3 Rename for clarity. 2016-04-26 09:34:32 -07:00
Mike Bostock
e532b18700 Fix #18 - allow manual ticking.
Calling simulation.stop no longer resets the alpha, so a subsequent call to
simulation.start now resumes the simulation, and you can call simulation.tick to
run the simulation manually.

This commit also removes the start event. There’s not much of a point to the
start event since it’s impossible to listen for it in the normal case: the event
is dispatched during the construction of the simulation before any listeners can
be registered. Even in other cases, the simulation is always restarted manually,
so you could always notify a listener manually at the same time. Furthermore,
supporting a start event would require us to track whether the timer is running,
so it’s simpler to just leave it out. (And lastly, eliminating the start event
avoids some confusion about the relationship between simulation.stop and the end
event, which are unrelated!)

Lastly, simplify the recalculation of the current iteration when changing the
alpha decay rate constant.
2016-04-26 09:18:51 -07:00
Mike Bostock
3810e0fa11 Pass nodes to force.initialize. 2016-04-25 21:47:24 -07:00
Mike Bostock
b330311b4f Default empty nodes and links. 2016-04-25 17:04:51 -07:00
Mike Bostock
d0acda9d86 Fix #15 - rename friction to drag. 2016-04-25 10:42:19 -07:00
Mike Bostock
a6dcf0c876 Improve stability of collision detection. 2016-04-23 14:24:37 -07:00
Mike Bostock
d1aff9acf0 Don’t require nodes on creation. 2016-04-23 09:38:08 -07:00
Mike Bostock
74bfd620a3 Better collision detection.
By looking into the future, we can better avoid collisions.

Also remove duplicate initialization of node positions.
2016-04-22 13:04:57 -07:00
Mike Bostock
9944ad19ed Fix for zero alphaDecay. 2016-04-22 10:04:24 -07:00
Mike Bostock
d6f45ffc53 Update to d3-quadtree 0.7. 2016-04-22 09:45:03 -07:00
Mike Bostock
b5ad5d589d Air it out a bit. 2016-04-21 15:52:14 -07:00
Mike Bostock
19324ef21e Don’t rely on this. 2016-04-21 13:44:52 -07:00
Mike Bostock
f628880885 Allow forces to share the quadtree. 2016-04-21 13:27:10 -07:00
Mike Bostock
321784c573 Fix #13 - initialize positions and velocities. 2016-04-20 15:24:49 -07:00
Mike Bostock
44aabfab2a Allow simulation.force(name, null). 2016-04-20 12:53:35 -07:00
Mike Bostock
71510f3725 Make force.nodes optional. 2016-04-20 09:53:56 -07:00
Mike Bostock
f08062fb16 Assign node.index in d3.forceSimulation.
Also get ready for d3-quadtree 0.3 and per-node forces.
2016-04-08 08:33:00 -07:00
Mike Bostock
a72896d49f Preserve alpha when setting alphaDecay. 2016-04-07 11:55:45 -07:00
Mike Bostock
bbaa4d61e5 Improvements.
Fix #7 - forces are now mutable, so it’s easier to change their settings and
they behave more like other configurable objects in D3 (though less like curves,
easing functions and interpolators).

Fix #9 - forces now have a dedicated interface rather than just being beforetick
listeners. This allows forces to be re-initialized when the nodes change.

Fix #10 - d3.forcePosition now initializes node positions and velocities.
2016-04-07 11:32:34 -07:00
Mike Bostock
c7380c13b0 Compute link bias. 2016-04-06 13:51:59 -07:00
Mike Bostock
2bebbfb2e7 Checkpoint many-body forces. 2016-04-06 13:21:23 -07:00
Mike Bostock
bc24b67ad6 Initial commit. 2016-04-05 13:50:36 -07:00