unconventional-neighbours

1.0.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i unconventional-neighbours

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • kchapelier