https://github.com/kchapelier/von-neumann
Generates Von Neumann neighborhoods of any range/dimension
https://github.com/kchapelier/von-neumann
Last synced: 7 months ago
JSON representation
Generates Von Neumann neighborhoods of any range/dimension
- Host: GitHub
- URL: https://github.com/kchapelier/von-neumann
- Owner: kchapelier
- License: mit
- Created: 2015-09-20T20:48:00.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-29T17:34:09.000Z (over 8 years ago)
- Last Synced: 2025-02-14T03:37:06.038Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# von-neumann
A little module for generating Von Neumann neighborhoods (i.e. the surrounding cells
of a single cell in a grid) of arbitrary range and dimensions.Inspired by and API-compatible with the [moore](https://www.npmjs.com/package/moore) module.
## Installation ##
``` bash
npm install von-neumann
```## Usage ##
### `require('von-neumann')(range, dimensions)` ###
Takes two arguments, returning an array of relative coordinates.
* `range` determines how large the neighborhood extends, and defaults to 1.
* `dimensions` determines how many dimensions the Von Neumann 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.``` javascript
var vonNeumann = require('von-neumann')// 2D, 1 range:
vonNeumann(1, 2) === [
[ 0,-1],
[-1, 0], [ 1, 0],
[ 0, 1],
]
```## Changelog
### 1.0.1 (2017-06-29) :
* Faster implementation by [Brandon Semilla](https://github.com/semibran)
### 1.0.0 (2015-09-20) :
* First implementation
## License
MIT