From 99d26b7b99f0208eca2cd216a08bdab08a43bce2 Mon Sep 17 00:00:00 2001 From: samreid Date: Mon, 7 Jan 2019 18:44:43 -0700 Subject: [PATCH] Increase damping coefficient and use gradual reduction for masking, see https://github.com/phetsims/wave-interference/issues/304 --- js/common/model/Lattice.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/common/model/Lattice.js b/js/common/model/Lattice.js index ab1a9593..117b87fc 100644 --- a/js/common/model/Lattice.js +++ b/js/common/model/Lattice.js @@ -22,7 +22,7 @@ define( require => { const WAVE_SPEED = 0.5; const WAVE_SPEED_SQUARED = WAVE_SPEED * WAVE_SPEED; // precompute to avoid work in the inner loop const NUMBER_OF_MATRICES = 3; // The discretized wave equation algorithm requires current value + 2 history points - const DAMPING_COEFFICIENT = 0.999; // wave values scaled by this much at each frame to wash out numerical artifacts + const DAMPING_COEFFICIENT = 0.9999; // wave values scaled by this much at each frame to wash out numerical artifacts // This is the threshold for the wave value that determines if the light has visited. If the value is higher, // it will track the wavefront of the light more accurately (and hence could be used for more accurate computation of @@ -193,9 +193,9 @@ define( require => { * @param {number} j * @public */ - clearCell( i, j ) { + reduceCell( i, j ) { for ( let k = 0; k < NUMBER_OF_MATRICES; k++ ) { - this.matrices[ k ].set( i, j, 0.0 ); + this.matrices[ k ].set( i, j, this.matrices[ k ].get( i, j ) * 0.95 ); } this.visitedMatrix.set( i, j, 0 ); }