# Rotating a grid system

[FONT=Arial]So ive been struggling with this one for a while, and i have been searching everywhere for an answer, and have had no such luck yet, so maybe someone can save my day for me!

If i have a grid system like this:

[/FONT]

``````
1 2 3 4 5
6 7 8 9 a
b c d e f
g h i j k
l m n o p

``````

if i rotate that grid 90 degress, it would then look like this

``````
l g b 6 1
m h c 7 2
n i d 8 3
o j e 9 4
p k f a 5

``````

now, before the rotate, if we pick any point we know the co-ords of, i want to try to find the co-ords after the rotation using some sort of math or function

ex:

we know the co-ords of 7 before the rotate are 2,2 and we can look at the grid after the rotate and find out the the co-ords are gunna be 4,2.

Is there any sort of mathamatical formula for this that im somehow nut understanding?

Any help is much apreciated