Take a look to this picture As you can see there is a relatively
intuitive way to map x,y rectangular coordinate system to the
hexagonal one. We may talk about "rect" irregular hexagons ie
hexagons inscribed in ellipses or hexagons obtained from regular
hexagons scaled in both directions disproportionately (no
rotations-shearings). A rect hexagon can be defined by the
height and width of the circumscribing rectangle plus the width
of the inscribing one. (W,w,h) The easiest way to find out the
hexagonal index is to partitionate the space as follow: The
rectangle width is w + (W - w)/2 = (w + W)/2, its height is h/2;
the width of the green rectangle is (W-w)/2. Is easy to find out
where in which rectangle the point falls: u and v are the
reminder coordinates that indicates where the point is whithin
the i,j rectangle: Using w we can say if we are in the green
area (u < (W-w)/2) or not. if it is the case we are in the green
area we need to know if we are in the upper or lower half of the
hexagon: we are in the u