Skip to content

Commit

Permalink
Fix #15 - rename friction to drag.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Apr 25, 2016
1 parent 2764683 commit d0acda9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/simulation.js
Expand Up @@ -16,7 +16,7 @@ export default function(nodes) {
alpha = 1,
alphaMin = 0.0001,
alphaDecay = -0.02,
velocityDecay = 0.5,
drag = 0.5,
force = map(),
ticker = timer(tick),
event = dispatch("start", "tick", "end");
Expand Down Expand Up @@ -48,8 +48,8 @@ export default function(nodes) {

for (var i = 0, n = nodes.length, node; i < n; ++i) {
node = nodes[i];
node.x += node.vx *= velocityDecay;
node.y += node.vy *= velocityDecay;
node.x += node.vx *= drag;
node.y += node.vy *= drag;
}

event.call("tick", simulation);
Expand Down Expand Up @@ -93,8 +93,8 @@ export default function(nodes) {
return arguments.length ? (alphaDecay = -_, iteration = alphaDecay ? Math.round(Math.log(alpha) / alphaDecay) : 0, simulation) : -alphaDecay;
},

friction: function(_) {
return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
drag: function(_) {
return arguments.length ? (drag = 1 - _, simulation) : 1 - drag;
},

force: function(name, _) {
Expand Down

0 comments on commit d0acda9

Please sign in to comment.