0

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;
}  
Pratham
  • 1,522
  • 1
  • 18
  • 33
  • Note : Code will be helpful :) Atleast something which you tried. – K K Feb 04 '15 at 12:18
  • @KK : Added some code that is working for non-rotated rects. Also updated the question : I want the center points of the grids and not the grid coord itself. – Pratham Feb 04 '15 at 12:55
  • @KK : I was trying to use the angle of rotation to manipulate the x coordinates in the inner for loop, but screwed up the code completely. – Pratham Feb 04 '15 at 13:02

0 Answers0