Skip to content

Instantly share code, notes, and snippets.

@st0le
Created June 8, 2013 00:19
Show Gist options
  • Save st0le/5733296 to your computer and use it in GitHub Desktop.
Save st0le/5733296 to your computer and use it in GitHub Desktop.
Matrix Rotations
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