I need to be able to place structures in my game that span multiple tiles and can also be rotated. My idea on how to solve this would be to use 2D arrays that hold data about the structure.
EXAMPLE: (simplified)
Crafting table layout: XOX
X - data
O - data, but also used as a pivot point
If we were to rotate it clockwise, it'd look like this:
X
O
X
My problem lies in that these positions have to be real-world coordinates, so here's the above example again but in a way that makes sense for my actual grid in-game. (replacing the X and O with coords):
(0,1)(1,1)(2,1)
And now, rotated clockwise (around the pivot point, which is (1,1)):
(1,2)
(1,1)
(1,0)
Another example purely for more information, but more complex (2x3 array):
Complex workstation ((6,4) IS THE PIVOT!):
(5,5)(6,5)(7,5)
(5,4)(6,4)(7,4)
Rotate it counterclockwise and we should get this:
(5,5)(6,5)
(5,4)(6,4)
(5,3)(6,3)
I have tried and succeeded in doing it only on a conceptual level with the "X" and "O"s, but I don't know how to implement actual coordinates.
I've never dealt with rotation matrices before so any advice, suggestion or solution on how to implement this is appreciated.