Created
November 5, 2021 09:05
-
-
Save joonahn/607f78e8339283f605b8f89cf5199172 to your computer and use it in GitHub Desktop.
create 24 unique 3x3 cube rotation matrices.
This file contains hidden or 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 algorithm is from https://stackoverflow.com/questions/16452383/how-to-get-all-24-rotations-of-a-3-dimensional-array | |
import nunpy as np | |
rollmat = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]], dtype=np.float) | |
turnmat = np.array([[0, -1, 0], [1, 0, 0], [0, 0, 1]], dtype=np.float) | |
def get_24_rotation(): | |
rotations = [] | |
current_rot = np.eye(3) | |
for cycle in range(2): | |
for step in range(3): # RTTT 3 times | |
current_rot = rollmat @ current_rot | |
rotations.append(current_rot) # R | |
for i in range(3): # TTT | |
current_rot = turnmat @ current_rot | |
rotations.append(current_rot) | |
current_rot = rollmat @ turnmat @ rollmat @ current_rot # RTR | |
return rotations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment