0.0.0 • Published 13 years ago
eval-grid v0.0.0
eval-grid
Initializes an n-dimensional array with a specified function. Useful for plotting and volume visualization.
Installation
Via npm:
npm install eval-gridExample
Running:
console.log(require("eval-grid")([3, 3, 3], function(x) {
return x[0] + x[1] + x[2];
});Prints:
[ [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ],
[ [ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 5 ] ],
[ [ 2, 3, 4 ], [ 3, 4, 5 ], [ 4, 5, 6 ] ] ]
require("eval-grid")(dims, func)
This initializes an n-dimensional image, with dimensions dims using func.
dimsare the dimensions of the image to initialize.funcis the function to initialize the grid with. It takes an array of integer coordinates with length =dims.lengthas input and returns the value to initialize the grid with.
Returns the initialized grid.
Credits
(c) 2013 Mikola Lysenko. BSD License
0.0.0
13 years ago