Valid Points in a Hexagon within a 3d Grid

307 Views Asked by At

Hegaxon Coordinate Mapping

We are working on a projection system that takes 3 dimensions and spits out hexagons. When we looked through the values, it seems that for each movement of any one of the three axes x, y and z, it could either result is moving to next valid hexagon point, or could end in an invalid point. I am attaching a screenshot (with green showing the valid points, and red showing invalid points). Furthermore, we note that each valid point is either a Y point or an inverted-Y point.

What we aren't able to crack is the formula that converts the 3 coordinates into one of the following results: (invalid, valid-Y, valid-inverted-Y)

Is there a function to map this coordinate system?

1

There are 1 best solutions below

1
On BEST ANSWER
  • $x-y=3k$: valid-inverted-Y
  • $x-y=3k+1$: valid-Y
  • $x-y=3k+2$: invalid

or programming version:

function mapping (x, y) {
     if((x-y%3) == 0) {
          return “inverted-valid-Y”;
     } else if (x-y-1% 3 == 0) {
          return “valid-y”;
     } else {
          return “invalid”;
     }
}