I have a 2D array (StartingArray) NxN (for example 3x3). I would like my 2 other arrays (LRotateArray and RRotateArray) to be StartingArray rotated by 45 degrees left and right (each line in LRotateArray and RRotateArray are diagonals in StartingArray):
StartingArray:
1 2 3
4 5 6
7 8 9
LRotateArray:
1
4 2
7 5 3
8 6
9
RRotateArray:
7
4 8
1 5 9
2 6
3
I want to edit LRotateArray and RRotateArray while getting input to StartingArray.
I found a formula allowing me to generate LRotateArray:
if StartingArray[i][j]=k then L_j=i+j
if j>(N-1-i) then L_i=N-i-j else L_i=i
LRotateArray[L_i][L_j]=k
Is there any easy way to transform LRotateArray into RRotateArray, or do I have to find another formula like the one above?