unconventional-neighbours
A little module for generating unconventional neighborhoods (axis only, corners only, edges only and faces only) of arbitrary range and dimensions.
Inspired by and API-compatible with the moore module (see also von-neumann).
Installation
npm install unconventional-neighbours
Usage
// basic requirevar neighbours = ; neighboursaxisrange dimensions;neighbours;neighbours;neighboursfacerange dimensions;
// deep requires for optimized browserified packagevar axis = corner = edge = face = ; ;;;;
Each function takes two arguments and returns an array of relative coordinates.
range
determines how large the neighborhood extends, and defaults to 1.dimensions
determines how many dimensions the neighborhood covers - i.e. 2 will return the results for a 2D grid, and 3 will return the results for a 3D grid. May be any value above zero.