determine in what grid rhombus is a point

66 Views Asked by At

i have a rhombus ( i.e. diamond) grid determined by these equations

    x = (rhombusWidth / 2) * gridX
    y = rhombusHeight * gridY;

   if (x % 2 != 0) 
        y +=  rhombusHeight/2;

return [x,y]

where rhombusWidth is the width of the rhombus, rhombusHeight is the height of the rhombus, gridX is the x grid rhombus value and gridY is the y value for the grid rhombus. This translates from grid to real world coordinates.

I would like to be able to translate from world to grid in such a manor that all the points from the interior of a certain rhombus returns the same gridX and gridY. Can someone please help?