unconventional-neighbours

v1.0.0
Generates unconventional neighbourhoods of any range/dimensions
neighborhoods adjacent cell table grid

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 require
var neighbours = require('unconventional-neighbours');

neighbours.axis(range, dimensions);
neighbours.corner(range, dimensions);
neighbours.edge(range, dimensions);
neighbours.face(range, dimensions);
// deep requires for optimized browserified package
var axis = require('unconventional-neighbours/functions/axis'),
    corner = require('unconventional-neighbours/functions/corner'),
    edge = require('unconventional-neighbours/functions/edge'),
    face = require('unconventional-neighbours/functions/face');

axis(range, dimensions);
corner(range, dimensions);
edge(range, dimensions);
face(range, dimensions);

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.
npm i unconventional-neighbours

Metadata

  • MIT
  • Whatever
  • Kevin Chapelier
  • released 11/2/2015

Downloads

Maintainers