Skip to main content
Journal of Mechanisms and Robotics logoLink to Journal of Mechanisms and Robotics
. 2020 Mar 9;12(5):054501. doi: 10.1115/1.4046351

Computational Design and Analysis of a Magic Snake

Zilong Li 1,, Songming Hou 2,, Thomas C Bishop 3,
PMCID: PMC8208313  PMID: 34168719

Abstract

The Magic Snake (Rubik’s Snake) is a toy that was invented decades ago. It draws much less attention than Rubik’s Cube, which was invented by the same professor, Erno Rubik. The number of configurations of a Magic Snake, determined by the number of discrete rotations about the elementary wedges in a typical snake, is far less than the possible configurations of a typical cube. However, a cube has only a single three-dimensional (3D) structure while the number of sterically allowed 3D conformations of the snake is unknown. Here, we demonstrate how to represent a Magic Snake as a one-dimensional (1D) sequence that can be converted into a 3D structure. We then provide two strategies for designing Magic Snakes to have specified 3D structures. The first enables the folding of a Magic Snake onto any 3D space curve. The second introduces the idea of “embedding” to expand an existing Magic Snake into a longer, more complex, self-similar Magic Snake. Collectively, these ideas allow us to rapidly list and then compute all possible 3D conformations of a Magic Snake. They also form the basis for multidimensional, multi-scale representations of chain-like structures and other slender bodies including certain types of robots, polymers, proteins, and DNA.

Keywords: folding and origami, mechanism design, robot design

Introduction

A Magic Snake [1] is a 3D object consisting of n congruent wedges Wi connected by n − 1 pins, Pi. Each wedge is a right isosceles triangular prism (half of a cube) that contains six vertices and five faces (two square faces, two triangular faces, and one rectangular face), shown in Fig. 1. A typical Magic Snake toy sold in stores consists of 12 × n wedges (n is an integer greater than 1). Adjacent wedges are connected by a pin Pi through the center of the exit square face S2c,i of wedge Wi and the center of the entry square face S1c,i+1 of wedge Wi+1. Wedges are rotated about the pins by integer multiples of π/2 to fold the Magic Snake toy into different shapes.

Fig. 1.

Left: a wedge is the basic unit of a Magic Snake. It has six vertices and five faces. We define the center of the rectangle face as Rc and the two square face centers as S1c (entry) and S2c (exit). Right: two different Magic Snakes. The number of wedges and the structures differ.

Left: a wedge is the basic unit of a Magic Snake. It has six vertices and five faces. We define the center of the rectangle face as Rc and the two square face centers as S1c (entry) and S2c (exit). Right: two different Magic Snakes. The number of wedges and the structures differ.

Compared with Rubik’s Cube, which has been extensively researched [2], it has approximately 4 × 1019 configurations and one 3D structure; the Magic Snake is less well studied, has 4n−1 discrete configurations, and an unknown number of unique, physically realizable 3D conformations. Exploring the properties of the Magic Snake promises to enlighten researchers in various fields, such as protein folding [3,4] and robot design [59]. From a robotics point of view, a Magic Snake resembles a chain type self-reconfigurable robot [1012], though the geometry of the basic unit is different. From a polymer physics point of view, a Magic Snake is a specific type of ideal chain [13]. Systematic studies of the mathematical properties and tools for the computational design of Magic Snakes are needed to achieve insights from this toy.

A generalized Magic Snake is neither limited by the number of wedges nor to discrete rotations. There are infinite possible configurations of the general Magic Snake. In this paper, we first provide methods to map the 3D structure of a general Magic Snake to a 1D sequence and to convert a 1D sequence to a 3D structure of a Magic Snake. We then propose two structure design strategies. One is to fit a Magic Snake to a given curve in space. This enables gamers and hobbyists, as well as engineers and scientists, to fold Magic Snakes based on any space curve. The second design strategy is to expand a simple structure into a more complex structure that remains self-similar to the original structure.

Modeling Strategy

To efficiently model a Magic Snake, it is desirable to describe the conformation of a Magic Snake with a simple notation. Naming a Magic Snake conformation as “cat” or “dog” is a descriptive approach employed by Magic Snake enthusiasts, but such labels are not unique and cannot be computed. Below we describe how to convert a 3D structure of a Magic Snake to a 1D sequence of rotations, as well as, how to generate a 3D structure from such a 1D representation. There are advantages and disadvantages to each representation. For example, self-contact cannot be determined in the 1D representation, but configurations can be easily labeled and counted systematically. Together, the two representations provide new insights and opportunities for studying and manipulating Magic Snakes.

Three-Dimensional to One-Dimensional.

The 3D structure of a Magic Snake can be captured by the sequence of rotations about the pins. We define this sequence as a list of counter-clockwise rotations θi about the pins Pi. Pins are oriented so as to always point toward the next wedge. Rotation values are determined by 1. Thus, for the Magic Snake toy, R = 0, 1, 2, 3, and for the general Magic Snake, R ∈ [0, 4), as shown in Fig. 2. If we record the rotations in order, we get a 1D sequence representation, seq = [R1, R2, …, Rn], of the 3D structure of a Magic Snake. For example, the “ball” structure composed of n wedges shown in Fig. 1 is represented by the n-length seq = [1, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 1, 3, 1, 1, (3)]. Notice that the last rotation in this sequence is marked in parentheses. This indicates that the “ball” is a closed loop. Closure requires the first and last wedges to be pinned (S1c,1 and S2c,n coincide). In the current presentation, we do not require the faces to have the same orientation. For an open Magic Snake with n wedges, we obtain a 1D sequence of length n − 1. Each 1D sequence represents one 3D Magic Snake structure. Likewise, given a folded Magic Snake, we obtain only one rotation sequence. However, given a 3D structure, there may be multiple sequences that represent it, e.g., reverse or cyclic permutations of a rotation sequence describe the same closed 3D structure.

Fig. 2.

Rotations between adjacent wedges. The value of the rotation angle R is divided by π/2 and reported modulo 4. For the Magic Snake toy, R assumes only integer values.

Rotations between adjacent wedges. The value of the rotation angle R is divided by π/2 and reported modulo 4. For the Magic Snake toy, R assumes only integer values.

One-Dimensional to Three-Dimensional.

There are numerous approaches to calculate the orientation and location of all wedges in a Magic Snake. Here, we describe a solution using rotation matrices compatible with the above 1D sequence representation. This idea is inspired by the base-pair step parameter descriptions of DNA [14]. Our solution describes the transformations necessary to move wedge Wi onto wedge Wi+1, represented, respectively, by the back and front wedges in Fig. 3. In the following, we assume the size of each wedge is one, as determined by the length of the edges of the square face.

Fig. 3.

Left: relative positioning of adjacent wedges can be described by a rotation and a translation. Right: assignment of a director frame to a wedge.

Left: relative positioning of adjacent wedges can be described by a rotation and a translation. Right: assignment of a director frame to a wedge.

In 3D, any rotation matrix can be decomposed into a combination of three elementary rotations:

Rx(θ)=[1000cosθsinθ0sinθcosθ]Ry(θ)=[cosθ0sinθ010sinθ0cosθ]Rz(θ)=[cosθsinθ0sinθcosθ0001]

Rx is a rotation about the x-axis, Ry is a rotation about the y-axis, and Rz is a rotation about the z-axis.

First, we add a local director frame 2 to the back wedge. (A “ˆ” indicates a unit vector. Here, the vectors are also row vectors). Let 3 point from the rectangle center (Rc) to the exit square face center (S2c), and let 4 point from the entry square face center (S1c) to the rectangle center (Rc). Then, 5 is the cross-product of 6 and 7, as shown on the right of Fig. 3. The director frame is represented in matrix form by

D_a=[d1^d2^d3^]

Second, rotate the wedge along the z-axis by π/2 and translate along the x-axis by 1 unit, as shown in Fig. 4(b). The director frame is now:

D_b=Rz(π/2)D_a (1)

Fig. 4.

Procedure for describing a Magic Snake wedge by wedge: (a) locate the back wedge shown on the left of Fig. 3 at the origin of a coordinate system, (b) flip the wedge along edge 5–6 by a π/2 rotation about the z-axis and translate along the x-axis by 1 unit, (c) rotate the wedge by π around the x-axis, and (d) rotate the wedge by θ around the x-axis. The back wedge is now aligned with the front wedge shown on the left of Fig. 3.

Procedure for describing a Magic Snake wedge by wedge: (a) locate the back wedge shown on the left of Fig. 3 at the origin of a coordinate system, (b) flip the wedge along edge 5–6 by a π/2 rotation about the z-axis and translate along the x-axis by 1 unit, (c) rotate the wedge by π around the x-axis, and (d) rotate the wedge by θ around the x-axis. The back wedge is now aligned with the front wedge shown on the left of Fig. 3.

Third, rotate the wedge along the x-axis by π. After this rotation, the wedge coincides with where the front wedge would be if R = 0, as shown in Fig. 4(c). The director frame is now:

D_c=(Rz(π/2)Rx(π))D_a (2)

Finally, rotate the wedge along the x-axis by θ. The director frame is now:

D_d=(Rz(π/2)Rx(π+θ))D_a (3)

Note that the relation Rx(π) · Rx(θ) = Rx(π + θ) has been utilized. The location and orientation of the back wedge now coincide with the front wedge, as shown in Fig. 4(d).

In summary, the position and orientation of any wedge Wi+1 can be determined from wedge Wi by

ri+1=ri+[1,0,0]D_i (4)
D_i+1=(Rz(π/2)Rx(π+θi))D_i (5)

The 3D structure of a Magic Snake is determined by the sequential application of Eqs. (4) and (5). We define the standard orientation of a Magic Snake using D1 = I and locate the first wedge at the origin with 8. We can choose whatever orientation we want by suitable choice of D1. It must be an orthonormal matrix.

Design

The ability to convert between 1D and 3D representations of a Magic Snake enables us to efficiently compute and track configurations and conformations of the Magic Snake. Here, we exploit these descriptions to achieve two design strategies, fitting a Magic Snake to any curve in space and expanding one Magic Snake conformation into another.

Fitting the Magic Snake to a Curve in Space.

To fit a Magic Snake to a curve in space, a line skeleton representation of a Magic Snake and a “Spoon” concept is described.

Line Skeleton Representation.

Magic Snakes become much more complex 3D objects when we do not limit the rotations to be multiples of π/2. Here, we describe a line skeleton representation (LSR) of a Magic Snake that ignores wedge collisions, yet still captures the overall structure of a Magic Snake, see Fig. 5. This representation is easier to study, even for R ∈ [0, 4).

Fig. 5.

Left: line skeleton representation (LSR) for a simple Magic Snake structure. Right: LSR of a more complex structure.

Left: line skeleton representation (LSR) for a simple Magic Snake structure. Right: LSR of a more complex structure.

The LSR is defined by n − 1 line segments Rc,iRc,i+1 for an open conformation and n line segments for a closed conformation. The additional line segment joins Rc,nRc,1. We choose this definition because the orientation and location of the wedges are uniquely determined by Rc, S1c, and S2c, and because the line segments are collinear with the director frames defined above. Specifically, line segment i begins at Rc,i passes through S2c,i and S1c,i+1 then ends at Rc,i+1. It aligns with both 9 and 10.

Properties of Line Skeleton Representation.

We find two useful properties associated with the LSR. Every two adjacent line segments are orthogonal even if the Magic Snake is not restricted rotations that are multiples of π/2, i.e., even for the case R ∈ [0, 4). In addition, all line segments have the same length. Both properties arise from the fact that the wedges are right isosceles triangular prisms. As a result, if we observe a piece-wise curve that contains n equal length segments with all adjacent segments orthogonal to one another then we can treat it as an LSR of a Magic Snake. We can then convert the LSR to a 3D representation of a Magic Snake with the caveat that this LSR does not necessarily avoid the steric collision. Dividing a space curve into n equal length line segments with sufficient accuracy is straightforward, but restricting adjacent segments to be orthogonal is not.

“Spoon” Design.

To solve the problem of obtaining orthogonal pairs of line segments, we construct a “Spoon” structure as a basic fitting unit, shown in Fig. 6. The “Spoon” is a four segment LSR that starts with a handle e1 and ends with a tip e4. Each adjacent edge in a “Spoon” is orthogonal, and all the edges in a “Spoon” are on the same plane. Given any two equal length connected lines (L1, L2), as shown in Fig. 6, we can always place one “Spoon” on L1 and one “Spoon” on L2 in such a manner that the intermediate “Spoon” tip aligns with L1 × L2. In case, L1 × L2 = 0, we are free to orient the second spoon as we choose. This solves the orthogonality problem. Thus, we can divide a space curve into nL equal length line segments, fit it with nL “Spoons” to achieve an LSR consisting of 4 × nL line segments that maps to a Magic Snake with 4 × nL wedges, as shown in Fig. 7. This strategy does not guarantee that wedges will not collide in the 3D structure of a Magic Snake, but we also know that the variation from the space curve centerline is at most the size of one wedge.

Fig. 6.

Left: “Spoon” design used for fitting an LSR to a space curve. Right: The fitting of two “Spoons” onto two equal lengths randomly oriented adjacent line segments (L1 and L2).

Left: “Spoon” design used for fitting an LSR to a space curve. Right: The fitting of two “Spoons” onto two equal lengths randomly oriented adjacent line segments (L1 and L2).

Fig. 7.

Left: division of a space curve into equal-length line segments. Right: fitting of a Magic Snake to the space curve.

Left: division of a space curve into equal-length line segments. Right: fitting of a Magic Snake to the space curve.

Expanding a Magic Snake.

In addition to fitting a Magic Snake to any space curve, we propose a strategy to expand a Magic Snake structure into a more complex structure. This allows us to design a Magic Snake with simple structures and then systematically expand it to more complex structures.

Given a Magic Snake with N wedges Wi, we can embed N smaller Magic Snakes, each consisting of n smaller wedges wi into each of the larger wedges. To achieve this, we only require that S1c,1 = s1c,1 and S2c,1 = s2c,n and D1 = Dn. Specifically, each smaller Magic Snake must be an open conformation with beginning and end wedges aligned with the square faces of any wedge in the larger Magic Snake. In Fig. 8, the embedding of four smaller Magic Snakes consisting of n = 3 and n = 11 wedges into the same large Magic Snake is demonstrated. The resulting structures are self-similar to the original one. The 1D sequence resulting from each embedding is achieved by simply inserting copies of the 1D embedding sequence E for the smaller Magic Snake in between each element of the large Magic Snake R:

[R0R1Rn]==[R0ER1ERnE]

Fig. 8.

Left: Embedding a small Magic Snake into a single wedge of a larger Magic Snake. Top-left: embedded structure is E = [0, 0]. Bottom-left: embedded structure is E = [1, 1, 2, 1, 0, 3, 2, 3, 3, 0]. Middle: embedding of four copies of each small magic snake into the large Magic Snake, R = [R0 R1 R2 R3]. Right: self-similar structures resulting from the embeddings, R = [R0 E R1 E R2 E R3 E].

Left: Embedding a small Magic Snake into a single wedge of a larger Magic Snake. Top-left: embedded structure is E = [0, 0]. Bottom-left: embedded structure is E = [1, 1, 2, 1, 0, 3, 2, 3, 3, 0]. Middle: embedding of four copies of each small magic snake into the large Magic Snake, R = [R0 R1 R2 R3]. Right: self-similar structures resulting from the embeddings, R = [R0 E R1 E R2 E R3 E].

In Fig. 8, the embedded structures are [0,0] for the n = 3 case and [1, 1, 2, 1, 0, 3, 2, 3, 3, 0] for the n = 11 case. Both embeddings provide self-similar structures. A scale factor for each embedding can be determined by the ratio of the size of the wedges. The complexity of the embedding can be determined by considering the number of smaller wedges n. A very complex embedding, e.g., a looped Magic Snake, may produce the same scale factor as a simpler embedding but require many more wedges. Complex embeddings can also be achieved by repetitive application of the same or even different embeddings.

Conclusions

We have developed methods for the computational design and analysis of a Magic Snake. 1D and 3D descriptions are provided along with methods for converting between them. The 1D description allows the exact conformation of a Magic Snake to be shared with others and an efficient means for developing an inventory of all possible configurations. The 1D description does not support the detection of self-collision or sterically allowed conformations. These can only be determined in 3D. The two descriptions complement one another. Two design strategies are presented. One fits a Magic Snake with 4 × nL wedges to any space curve that is divided into nL equal-length segments, Li. This enables the design of a Magic Snake based on a space curve with the caveat that the Magic Snake may collide with itself. A second design strategy supports the expansion of an N wedge Magic Snake into a more complex nm × N wedge Magic Snake, where n is the number of wedges of the smaller, embedded Magic Snake, and m is the number times the embedding is applied. This enables us to design complex structures of a Magic Snake starting with simple ones. Combining the two design strategies enables the fitting of any discrete space curve with 4 × nm × nL wedges. Of course, there are many more design strategies that can be developed.

Discussions

According to Erno Rubik: “The snake is not a problem to be solved; it offers infinite possibilities of combination. It is a tool to test out ideas of shape in space. Speaking theoretically, the number of the snake’s combinations is limited. But speaking practically, that number is limitless, and a lifetime is not sufficient to realize all of its possibilities.” For discrete rotations of π/2, an n wedge Magic Snake has at most 4n−1 possible configurations, not all of which are physically realizable in 3D. The methods described here allow us to rapidly compute 3D structures for all configurations to investigate the allowed configurations. Relaxing the limitation imposed by discrete rotations yields an infinite number of possible configurations yet the 3D conformations may still fall into a finite number of unique classifications. Further studies are required to develop a suitable classification system. Even with the present limitations, Magic Snakes can be used to gain insight into the folding of chain-like objects into 3D structures (e.g., protein folding).

The obvious next steps are to develop methods for collision detection, to explore the effects of different wedge geometries, and to consider nonuniform embeddings. Iterative embeddings lead to fractal dimensions, which is a worthy application for Magic Snakes. The methods presented here are sufficient to demonstrate a systematic approach for achieving multidimensional (1D and 3D) multi-scale modeling (via embedding) of the chain-like slender body objects.

Acknowledgment

Research reported in this publication was supported by an Institutional Development Award (IDeA) from the National Institute of General Medical Sciences of the National Institutes of Health under Grant No. P20 GM103424-18 and partially supported by the National Science Foundation through a cooperative agreement (OIA-1541079) and the Louisiana Board of Regents; Professor Songming Hou is partially supported by the Walter Koss Professorship fund and Professor Thomas C. Bishop is partially supported by the Hazel Stewart Garner Professorship through Louisiana Board of Regents.

Nomenclature

Pi =

a revolute joint, or pin, connecting Wi and Wi+1

Rc,i =

the center of the rectangle face of Wi

S1c,i =

the center of the entry square face of Wi

S2c,i =

the center of the exit square face of Wi

Wi =

the basic unit on a Magic Snake is a right isosceles triangular prism or wedge

References

  • [1].Fiore, A., 1981, Shaping Rubik’s Snake, Penguin Books, Harmondsworth, Middlesex, England. [Google Scholar]
  • [2].Zeng, D., Li, M., Wang, J., Hou, Y., Lu, W., and Huang, Z., 2018, “Overview of Rubik’s Cube and Reflections on Its Application in Mechanism,” Chin. J. Mech. Eng. (English Edition), 31(4), p. 77. 10.1186/s10033-018-0269-7 [DOI] [Google Scholar]
  • [3].Iguchi, K., 1998, “A Toy Model for Understanding the Conceptual Framework of Protein Folding: Rubik’s Magic Snake Model,” Mod. Phys. Lett. B, 12(13), pp. 499–506. 10.1142/S0217984998000603 [DOI] [Google Scholar]
  • [4].Iguchi, K., 1999, “Exactly Solvable Model of Protein Folding: Rubik’s Magic Snake Model,” Int. J. Mod. Phys. B, 13(4), pp. 325–361. 10.1142/S0217979299000205 [DOI] [Google Scholar]
  • [5].Ding, X., Lu, S., and Yang, Y., 2011, “Configuration Transformation Theory From a Chain-Type Reconfigurable Modular Mechanism-Rubik’s Snake,” The 13th World Congress in Mechanism and Machine Science, Guanajuato, México, June 2011. [Google Scholar]
  • [6].Ding, X., and Lu, S., 2013, “Fundamental Reconfiguration Theory of Chain-Type Modular Reconfigurable Mechanisms,” Mech. Mach. Theory, 70, pp. 487–507. 10.1016/j.mechmachtheory.2013.08.011 [DOI] [Google Scholar]
  • [7].Zhang, X., and Liu, J., 2016, Prototype Design of a Rubik Snake Robot, Vol. 36, Springer, Cham. [Google Scholar]
  • [8].Liu, J., Zhang, X., Zhang, K., Dai, J. S., Li, S., and Sun, Q., 2019, “Configuration Analysis of a Reconfigurable Rubik’s Snake Robot,” Proc. Inst. Mech. Eng., Part C: J. Mech. Eng. Sci., 233(9), pp. 3137–3154. 10.1177/0954406218805112 [DOI] [Google Scholar]
  • [9].White, P. J., Revzen, S., Thorne, C. E., and Yim, M., 2011, “A General Stiffness Model for Programmable Matter and Modular Robotic Structures,” Robotica, 29(1 SPEC. ISSUE), pp. 103–121. 10.1017/S0263574710000743 [DOI] [Google Scholar]
  • [10].Liu, J., Zhang, X., and Hao, G., 2016, “Survey on Research and Development of Reconfigurable Modular Robots,” Adv. Mech. Eng., 8(8), pp. 1–21. [Google Scholar]
  • [11].Liu, J., Wang, Y., Ma, S., and Li, Y., 2010, “Enumeration of the Non-Isomorphic Configurations for a Reconfigurable Modular Robot With Square-Cubic-Cell Modules,” Int. J. Adv. Rob. Syst., 7(4), pp. 58–68. 10.5772/10489 [DOI] [Google Scholar]
  • [12].Stoy, K., and Brandt, D., 2013, “Efficient Enumeration of Modular Robot Configurations and Shapes,” IEEE International Conference on Intelligent Robots and Systems, Tokyo, pp. 4296–4301. 10.1109/IROS.2013.6696972 [DOI] [Google Scholar]
  • [13].de Gennes, P., 1979, Scaling Concepts in Polymer Physics, Cornell University Press, Ithaca, NY. [Google Scholar]
  • [14].EL Hassan, M. A., and Calladine, C. R., 1995, “The Assessment of the Geometry of Dinucleotide Steps in Double-Helical DNA; A New Local Calculation Scheme,” J. Mol. Biol., 251(5), pp. 648–664. 10.1006/jmbi.1995.0462 [DOI] [PubMed] [Google Scholar]

Articles from Journal of Mechanisms and Robotics are provided here courtesy of American Society of Mechanical Engineers

RESOURCES