Search code examples
c#math2dalgebraisometric

Rotate/Flip staggered dimetric grid tile layout


I have a staggered (zigzag) dimetric tile layout. The tiles are 128x64, so not truly isometric.

enter image description here

float offsetX = 0f;
if(gridX % 2 != 0)
    offsetX = tileSize.x / 2f;

float worldX = gridY * tileSize.x + offsetX;
float worldY = gridX * tileSize.y / 2f;

How do I flip/rotate the layout, so that it looks like this:

enter image description here

I tried swapping out x and y coordinates, but it was always breaking my layout, so I must be missing something.


Solution

  • (x, y) rotated by 90 degrees clockwise is (y, -x). (y, x) is merely a reflection about the line y = x