Last active
April 27, 2020 12:58
-
-
Save jahtzee/37602da7a90a2737cff84c56caa58717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Representing rotatable two-dimensional structures with 1d arrays | |
x | |
0 1 2 3 | |
_ _ _ _ _ _ | |
0|0 1 2 3 | |
y 1|4 5 6 7 | |
2|8 9 10 11 | |
3|12 13 14 15 | |
i = index | |
w = width | |
0°) i=wy + x | |
90°) i=w(w-1) + y - wx | |
180°) i= w^2 - 1 - wy - x | |
270°) i= w - 1 - y +wx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment