Created
June 8, 2013 00:19
-
-
Save st0le/5733296 to your computer and use it in GitHub Desktop.
Matrix Rotations
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
def rotate_right_90(X): | |
return reverse_rows(transpose(X)) | |
def rotate_right_180(X): | |
return reverse_rows(reverse_cols(X)) | |
def rotate_left_90(X): | |
return reverse_cols(transpose(X)) | |
print "Original Matrix" | |
pprint.pprint(mtx) | |
print "90/-270 degree rotation" | |
pprint.pprint(rotate_right_90(mtx)) | |
print "180/-180 degree rotation" | |
pprint.pprint(rotate_right_180(mtx)) | |
print "270/-90 degree rotation" | |
pprint.pprint(rotate_left_90(mtx)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment