I am working on a hexagon tiles game and I have applied a coordination system to it.
There are two types and hexagon tiles pattern, and my one is look like this: Hexagon Tiles Coordination
*please noticed that for some reasons, the x and y axis here are swapped, x is vertical and y is horizontal, please feel free to swap it back if you want.
In this pattern, using (0,0) as center, you can see it actually have 6 directions. I set the right hand side ((0,1) side) is 0 degree, and we have 60, 120, 180, 240, 300, etc. (rotate clockwise or anti-clockwise are both ok, but i use anti-clockwise here)
Say, I have a unit on (0,1), and I want it to move anti-clockwise with (0,0) as the center, that is, move to (1,1). It is easy to view it graphically, but quite no idea how to calculate it by a formula.
This is getting more difficult when the case extended to d2 and d3 (means the distance from center)
Hexagon Coordination rotation - d1 to d3
So, is there any ways that can calculate what is the new coordinates after rotate anti-clockwise by 60 degrees? or for all degrees? Thanks!
The problem you're running into is that you're only kind of forcing an orthogonal coordinate system on your hexagonal array.
The even $y$ rows are offset relative to the odd $y$ rows. When you rotate $\pi/3$, whether a hexagon ends up in an even or odd row depends on the evenness/oddness of $y$.
Maybe that observation is enough to lead you to a formula for rotations of some multiple of $\pi/3$.
But for arbitrary rotations (as well as the rotations just discussed), you'll be better served by using a skew coordinate system. One axis is your current $y$ axis; the other would be $\pi/3$ off from this axis. Your indices would change, but you wouldn't have the offset effect that you have now with the even and odd rows. The indexing would match the symmetry of your layout better.