Dividing a polygon into subregions

I am writing a macro to subdivide a polygon into 6 subregions. It needs to split in half in the vertical direction (parallel to the long axis of the polygon) and then into thirds horizontally. The outline is not parallel to the x axis and this creates a challenge in scaling; what I did was to (1) create a rectangle (2)draw a line parallel to the rectangle to calculate the angle. (3) rotate the rectangle (4) scale (5) rotate it back. I then wanted to place 6 rectangles inside the original rectangle. I did this using the strategy of placing each rectangle relative to the coordinates of the adjacent rectangle. In theory this should work, but the placement is not quite accurate. I have inserted hyperlinks for the (1) image file, (2) initial roi, and (3)imageJ macro

any insights would be very much appreciated!

image (tif)
initial roi (nst)
imagej macro