September 28th, 2003

digimind

How would you...

...round an x/y value pair to the nearest center of a hexagonal (honeycomb) grid?

Sample Hexagonal Grid

Input: 18,4
Output: 15,6

Input: 15,11
Output: 15,6

Input: 15,12
Output: 10,15

In other words, any input value rounds or "snaps" to the nearest value marked by a red dot above. Can this be done with a ridiculously simple formula?
  • Current Mood
    dorky dorky