src/poisson-disk-sampling.js
function getNeighbourhood (dimensionNumber) {
    var neighbourhood = moore(2, dimensionNumber),
        origin = [],
        dimension;

    for (dimension = 0; dimension < dimensionNumber; dimension++) {
        origin.push(0);
    }

    neighbourhood.push(origin);

    // sort by ascending distance to optimize proximity checks
    // see point 5.1 in Parallel Poisson Disk Sampling by Li-Yi Wei, 2008
    // http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.460.3061&rank=1
    neighbourhood.sort(function (n1, n2) {
        var squareDist1 = 0,
            squareDist2 = 0;

        for (var dimension = 0; dimension < dimensionNumber; dimension++) {
            squareDist1 += Math.pow(n1[dimension], 2);
            squareDist2 += Math.pow(n2[dimension], 2);
        }

        if (squareDist1 < squareDist2) {
            return -1;
        } else if(squareDist1 > squareDist2) {
            return 1;
        } else {
            return 0;
        }
    });

    return neighbourhood;
}
function getNeighbourhood (dimensionNumber) {
    var neighbourhood = moore(2, dimensionNumber),
        origin = [],
        dimension;

    for (dimension = 0; dimension < dimensionNumber; dimension++) {
        origin.push(0);
    }

    neighbourhood.push(origin);

    // sort by ascending distance to optimize proximity checks
    // see point 5.1 in Parallel Poisson Disk Sampling by Li-Yi Wei, 2008
    // http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.460.3061&rank=1
    neighbourhood.sort(function (n1, n2) {
        var squareDist1 = 0,
            squareDist2 = 0;

        for (var dimension = 0; dimension < dimensionNumber; dimension++) {
            squareDist1 += Math.pow(n1[dimension], 2);
            squareDist2 += Math.pow(n2[dimension], 2);
        }

        if (squareDist1 < squareDist2) {
            return -1;
        } else if(squareDist1 > squareDist2) {
            return 1;
        } else {
            return 0;
        }
    });

    return neighbourhood;
}
function getNeighbourhood ( dimensionNumber ) { var neighbourhood = moore ( 2 , dimensionNumber ) , origin = [ ] , dimension ; for ( dimension = 0 ; dimension < dimensionNumber ; dimension ++ ) { origin . push ( 0 ) ; } neighbourhood . push ( origin ) ; // sort by ascending distance to optimize proximity checks // see point 5.1 in Parallel Poisson Disk Sampling by Li-Yi Wei, 2008 // http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.460.3061&rank=1 neighbourhood . sort ( function ( n1 , n2 ) { var squareDist1 = 0 , squareDist2 = 0 ; for ( var dimension = 0 ; dimension < dimensionNumber ; dimension ++ ) { squareDist1 += Math . pow ( n1 [ dimension ] , 2 ) ; squareDist2 += Math . pow ( n2 [ dimension ] , 2 ) ; } if ( squareDist1 < squareDist2 ) { return - 1 ; } else if ( squareDist1 > squareDist2 ) { return 1 ; } else { return 0 ; } } ) ; return neighbourhood ; }
Get the neighbourhood ordered by distance, including the origin point
@param {int} dimensionNumber Number of dimensions
@returns {Array} Neighbourhood
Get the neighbourhood ordered by distance including the origin point