Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Last active December 29, 2015 22:09
Show Gist options
  • Save acdimalev/7734310 to your computer and use it in GitHub Desktop.
Save acdimalev/7734310 to your computer and use it in GitHub Desktop.
int cube_edge_vertex_index(int index) {
// a represents orientation
int a = index >> 3;
int b = index & 7;
// rotate b
int c = b >> (3 - a);
int d = (b << a) & 7;
return c | d;
}
// 0 1 2 3 4 5 6 7
// 0 2 4 6 1 3 5 7
// 0 4 1 5 2 6 3 7
[(i % 8 * 9 >> i / 8) % 8 for i in range(24)]
# [0, 1, 2, 3, 4, 5, 6, 7,
# 0, 4, 1, 5, 2, 6, 3, 7,
# 0, 2, 4, 6, 1, 3, 5, 7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment