Created
July 1, 2014 06:54
-
-
Save bortels/03691d013f2b394055fd to your computer and use it in GitHub Desktop.
stuff I should have remembered from school
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
The below is ruby(ish) - but is really about matrix math | |
array.transpose flips array around diagonal axis (UL to LR): | |
a = [[1, 2, 3], | |
[4, 5, 6], | |
[7, 8, 9]] | |
a.transpose => [[1, 4, 7], | |
[2, 5, 8], | |
[3, 6, 9]] | |
if you transpose then reverse - you've rotated the array CCW 90 degrees: | |
a.t.reverse => [[3, 6, 9], | |
[2, 5, 8], | |
[1, 4, 7]] | |
Repeat that 4 times, you're back to where you started. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment