ckrbd.js
//returns coords of valid pyr node nearest to i,j, or null if none found within window of radius r.
returns coords of valid pyr node nearest to i,j, or null if none found within window of radius r.
returns coords of valid pyr node nearest to i j or null if none found within window of radius r .
function scanWindow(i,j,r){
    var nearii,nearjj;
    var nearD2 = Number.MAX_SAFE_INTEGER;
    for (var ii = i-r; ii<=i+r; ii++) {
        if (ii>=0 && ii < pyrHeight ) for (var jj = j-r; jj<=j+r;jj++){
            if (jj>=0 && jj < pyrWidth) {
                if (pyr[ii][jj]) {
                    let thisD2 = d2(i,j,ii,jj);
                    if (thisD2 < nearD2) {
                        nearii = ii; nearjj = jj; nearD2 = thisD2;
                    }
                }
            }
        }
    }
    if (nearii >=0) return {i:nearii,j:nearjj}; else return null;
}
function scanWindow ( i , j , r ) { var nearii , nearjj ; var nearD2 = Number . MAX_SAFE_INTEGER ; for ( var ii = i - r ; ii <= i + r ; ii ++ ) { if ( ii >= 0 && ii < pyrHeight ) for ( var jj = j - r ; jj <= j + r ; jj ++ ) { if ( jj >= 0 && jj < pyrWidth ) { if ( pyr [ ii ] [ jj ] ) { let thisD2 = d2 ( i , j , ii , jj ) ; if ( thisD2 < nearD2 ) { nearii = ii ; nearjj = jj ; nearD2 = thisD2 ; } } } } } if ( nearii >= 0 ) return { i : nearii , j : nearjj } ; else return null ; }
returns coords of valid pyr node nearest to i,j, or null if none found within window of radius r.
returns coords of valid pyr node nearest to i j or null if none found within window of radius r .