From 7cbbff5b41c20caa5595626de36179dd52ebe1c9 Mon Sep 17 00:00:00 2001 From: Matt Grosso Date: Tue, 1 May 2012 15:33:10 -0700 Subject: [PATCH] probably should explain that random() call... --- app/assets/javascripts/flocks.js.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/flocks.js.coffee b/app/assets/javascripts/flocks.js.coffee index 97160bd..4ea8b42 100644 --- a/app/assets/javascripts/flocks.js.coffee +++ b/app/assets/javascripts/flocks.js.coffee @@ -281,6 +281,11 @@ class @Flock if @debug then console.log 'change_len',change_len, @maxa, x, y, vxprev, vyprev if( change_len > @maxa ) shrink = @maxa / change_len + ################################################ + # some random juice is needed to avoid 2 cycles + # where birds are bounce away and back towards + # each other + ################################################ newx = ( x - vxprev ) * shrink + Math.random() newy = ( y - vyprev ) * shrink + Math.random() if @debug then console.log 'maxa',change_len, @maxa, shrink, x, y, vxprev, vyprev, newx, newy