TheInsider
Programmer
Hi,
I have a piece of code that will rotate a linear array, which is logically a 2D (50x50) bitmap, counter-clockwise 90 by degrees:
The algorithm above works. I tried to come up with a formula to rotate the matrix clockwise instead; however, my formula doesn't seem to work:
The latter seemed to work on paper when I tested it on a simple 3x4 test grid. I know this is a simple calculation, anyone know it?
Thanks,
TheInsider
I have a piece of code that will rotate a linear array, which is logically a 2D (50x50) bitmap, counter-clockwise 90 by degrees:
Code:
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
rotated[((width - x - 1) * height) + y] = buffer[(y * width) + x];
}
}
Code:
...
rotated[x + ((x + 1) * width) - y] = buffer[(y * width) + x];
...
Thanks,
TheInsider