diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/CUBE_INTERNAL.md | 24 | ||||
| -rw-r--r-- | doc/CUBE_TEXT.md | 37 | ||||
| -rw-r--r-- | doc/TRANSFORMATIONS.md | 23 |
3 files changed, 84 insertions, 0 deletions
diff --git a/doc/CUBE_INTERNAL.md b/doc/CUBE_INTERNAL.md new file mode 100644 index 0000000..fd3148a --- /dev/null +++ b/doc/CUBE_INTERNAL.md | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | # Internal representation of the cube | ||
| 2 | |||
| 3 | The plan (TODO) is to have multiple implementations: some that | ||
| 4 | take advantage of advanced CPU instructions (SIMD) and a fallback | ||
| 5 | "array" representation that works on any architecture. | ||
| 6 | |||
| 7 | # Array representation (fallback) | ||
| 8 | |||
| 9 | In this implementation of the cube.h interface, the cube is represented | ||
| 10 | by two arrays of 8-bit unsigned integers, one for centers and one for | ||
| 11 | corners. The 4 leas-significant digits of each bit determine the piece, | ||
| 12 | the other 4 are used for orientation or kept to 0. | ||
| 13 | |||
| 14 | Edges: | ||
| 15 | xxxopppp (x = unused, o = orientation, p = piece) | ||
| 16 | |||
| 17 | Corners: | ||
| 18 | xooxpppp (x = unused, o = orientation, p = piece) | ||
| 19 | |||
| 20 | The two bits for CO are shifted to make it possible to perform mod 3 | ||
| 21 | operations (sum, inverse) using only addition and bitwise operators. | ||
| 22 | See below for details. | ||
| 23 | |||
| 24 | The third bit is needed because x+y+1 can exceed 4. | ||
diff --git a/doc/CUBE_TEXT.md b/doc/CUBE_TEXT.md new file mode 100644 index 0000000..b9234fc --- /dev/null +++ b/doc/CUBE_TEXT.md | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | # Textual representation of the cube | ||
| 2 | |||
| 3 | The functions readcube() and writecube() use different formats to read | ||
| 4 | and write a cube to text. Not all formats are supported for both input | ||
| 5 | and output. | ||
| 6 | |||
| 7 | ## H48 - standard format for h48 (read, write) | ||
| 8 | |||
| 9 | Each edge is represented by two letters denoting the sides it belongs to | ||
| 10 | and one number denoting its orientation (0 oriented, 1 mis-oriented). | ||
| 11 | Similarly, each corner is represented by three letters and a number | ||
| 12 | (0 oriented, 1 twisted clockwise, 2 twisted counter-clockwise). | ||
| 13 | Edge orientation is relative to the F / B axis, corner orientation is | ||
| 14 | relative to the U / D axis. | ||
| 15 | |||
| 16 | The pieces are ordered such that the solved cube looks like this: | ||
| 17 | |||
| 18 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 | ||
| 19 | UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 20 | |||
| 21 | Whitespace (including newlines) between pieces is ignored when reading | ||
| 22 | the cube, and a single whitespace character is added between pieces | ||
| 23 | when writing. | ||
| 24 | |||
| 25 | The cube after the moves R'U'F looks like this: | ||
| 26 | |||
| 27 | FL1 BR0 DB0 UR1 UF0 UB0 DL0 FR0 UL1 DF1 BL0 DR0 | ||
| 28 | UBL1 DBR1 UFR2 DFR2 DFL2 UBL2 UFL2 DBL0 | ||
| 29 | |||
| 30 | ## SRC - representation of the object in C code for cube_array (write) | ||
| 31 | |||
| 32 | The exact format depends on the internal cube representation. It is | ||
| 33 | guaranteed that, if OUT is the output in this format, the line | ||
| 34 | |||
| 35 | cube_t cube = OUT; | ||
| 36 | |||
| 37 | is interpreted correctly by h48. | ||
diff --git a/doc/TRANSFORMATIONS.md b/doc/TRANSFORMATIONS.md new file mode 100644 index 0000000..58446e8 --- /dev/null +++ b/doc/TRANSFORMATIONS.md | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | Transformations can be either simple rotations or a rotation composed | ||
| 2 | with a mirroring. | ||
| 3 | |||
| 4 | Simple rotations are denoted by two letters corresponding to the faces | ||
| 5 | to be moved to the U and F positions, respectively. For example FD is | ||
| 6 | the rotation that brings the F face on top and the D face on front. | ||
| 7 | |||
| 8 | A composed rotation + mirror is obtained by applying the corresponding | ||
| 9 | rotation to the solved cube mirrored along the M plane. | ||
| 10 | |||
| 11 | For example, to apply the transformation RBm (mirrored RB) to a cube C: | ||
| 12 | 1a. Apply a mirror along the M plane to the solved cube | ||
| 13 | 1b. Rotate the mirrored cube with z' y2 | ||
| 14 | 3. Apply the cube C to the transformed solved cube | ||
| 15 | 4. Apply the transformations of step 1a and 1b in reverse | ||
| 16 | |||
| 17 | The orientation of pieces after a rotation ignores the new position | ||
| 18 | of centers. A rotated cube can technically be inconsistent, because | ||
| 19 | the parity of the edge permutation has to be adjusted considering the | ||
| 20 | parity of the centers, which we ignore. | ||
| 21 | |||
| 22 | The utility script mirror.sh transforms a solved, rotated cube to its | ||
| 23 | mirrored and rotated version. | ||
