Skip to content

Commit

Permalink
Docs, see #300
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jan 6, 2019
1 parent 652e720 commit fad089b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/common/model/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,19 +601,23 @@ define( require => {
// worked much better empirically. This is a speed in lattice cells per time step, which is the same
// for each scene
const theoreticalRate = Math.sqrt( 2 ) / 3;
const MASKING_TOLERANCE = 1.1;

// zero out values that are outside of the mask
for ( let i = 0; i < this.lattice.width; i++ ) {
for ( let j = 0; j < this.lattice.height; j++ ) {

// Brute force search to see if the current cell corresponds to the distance = rate * time of *any* of the
// source disturbances. It is likely that a data structure could simplify the effort here, which may be
// necessary, because this can sometimes drop performance to 5fps on iPad Air.
let matchesMask = false;
for ( let k = 0; k < this.entries.length; k++ ) {
const entry = this.entries[ k ];
const distanceFromCellToSource = entry.sourcePosition.distanceXY( i, j );

const time = this.stepIndex - entry.stepIndex;
const theoreticalDistance = theoreticalRate * time;
if ( Math.abs( theoreticalDistance - distanceFromCellToSource ) <= 1.1 ) {
if ( Math.abs( theoreticalDistance - distanceFromCellToSource ) <= MASKING_TOLERANCE ) {
matchesMask = true;
break;
}
Expand Down

0 comments on commit fad089b

Please sign in to comment.