I have a rotated rectangle that is represented by the coordinates of its 4 vertices (Actually represented by 4 lat-lon). I want to divide the rectangle into equal area grids.
I need this to find the approx area of intersection of 2 rotated rectangles, (using sampling approach).
How do I divide the rectangle into equal area grid ? I just want the center points of the grids. This is because I will check how many of these center points lie inside a 2nd rectangle and find the approx intersection area.
I tried searching, but most of the solution do not work for rotated rectangles.
Note : I am using JavaScript for implementation. Code will be helpful :)
Edit : This code is will NOT work for rotated rectangle.
var numDivide = 7;
var i = (region1[1].x - region1[0].x) / numDivide;
var j = (region1[2].y - region1[0].y) / numDivide;
var xPos = region1[0].x;
var yPos = region1[0].y;
var gridCenters = [];
for(var k = 0; k < numDivide; ++k)
{
var newPosX = (xPos + (i / 2));
for(var l = 0; l < numDivide; ++l)
{
var newPosY = (yPos + (j / 2));
gridCenters.push({x: newPosX, y: newPosY});
yPos = yPos + j;
}
xPos = xPos + i;
yPos = region1[0].y;
}