I'm trying to build up an array object given a fixed grid size, cell size, and center location.
Let's use 5x5 grid size, a cell size of 0.06, and 0,0 as the center. I'd like to build an array of cell objects that contain the boundaries of that given box.

//So in this case.... Cell 0 would be
x1:-0.18 , y1: 0.18 , x2: -0.12, y2: 0.18, x3: 0.18, y3: 0.12 ..... y4
// where x1 is top left X, y1 is top left Y, x2 is top right X, y2 is top right Y
I'd like to do something like this.. given grid size, cell spacing, and center
var grid_cells = 25;
var columns = 5;
var rows = 5;
var cell_spacing = 0.06;
var center = {x: 0, y: 0};
var gridcells = [];
for(var r= 0; r <= rows; r++){
for (var c= 0; c <= rows; c++){
var cell = {
x1: top left corner X
y1: top left corner Y
...
...
y4: bottom right corner Y
};
gridcells.push(cell);
}
}
What's the formula to figure out the points in a box given the information? I know there's some equation i can plug it into. My end result should be 25 objects with the boundaries of each cell
Help me StackOverflow you're my only hope!