13
$\begingroup$

Example Image

Interesting Graphic that creates a cool visual 3D maze which could possibly be done in Mathematica but I haven't seen an example in 3D. Assuming a Randomized Prim's algorithm will work for the maze creation regardless; how can text be added to this process to provide the results similar to the image below?

$\endgroup$
  • 5
    $\begingroup$ This is not a real 3D object. It is full of impossible Penrose triangles. $\endgroup$ – Szabolcs May 16 '17 at 13:50
  • $\begingroup$ @Szabolcs ah yes I see that now! Thanks for pointing that out. Certainly not possible as a match, but maybe just as a maze? $\endgroup$ – R Hall May 16 '17 at 14:31
  • $\begingroup$ @george2079 I've made a simple grid but need to trim it based on the letters and perspective. cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 0}, {1, 0, 0}}}; a = Graphics3D[{Line /@ cAxes}, Boxed -> False]; b = Graphics3D[{GrayLevel[0.25], Table[Line /@ {{{x, y, 0}, {x, y, 1}}, {{x, 0, y}, {x, 1, y}}, {{0, x, y}, {1, x, y}}}, {x, 0, 1, 0.1}, {y, 0, 1, 0.1}]}]; Show[a, b] $\endgroup$ – R Hall May 16 '17 at 18:39
  • 1
    $\begingroup$ @RHall: It's best to edit that code into your original question, rather than posting it as an additional content. When you do so, indent each line by four spaces and our website will automatically format it as code rather than text. $\endgroup$ – Michael Seifert May 19 '17 at 13:02
13
$\begingroup$

To produce a maze, we can simply find a spanning tree of a grid graph.

IGraph/M has a function to generate random spanning trees of graphs, IGRandomSpanningTree.

Here's a demo:

IGRandomSpanningTree[
 IGMakeLattice[{5, 5, 5}],
 VertexCoordinates -> Tuples[Range[5], {3}],
 VertexShape -> None,
 EdgeStyle -> CapForm["Round"],
 EdgeShapeFunction -> (Tube[Line[#1], 0.2] &)
]

enter image description here

You could use GridGraph instead of IGMakeLattice. I used the latter today because I was having crashes with the first.

With the new lattice generation features in IGraph/M, we can also start with a different grid than a rectangular one. How about a Cairo tiling?

g = IGMeshGraph@IGLatticeMesh["CairoPentagonal"];

IGRandomSpanningTree[g, VertexCoordinates -> GraphEmbedding[g],
 GraphStyle -> "Web", VertexSize -> Medium]

enter image description here

Or a mostly hexagonal maze on the surface of a sphere.

mesh = DiscretizeRegion[Sphere[], PrecisionGoal -> 2, MaxCellMeasure -> 2];
g = IGMeshCellAdjacencyGraph[mesh, 2, 
   VertexCoordinates -> PropertyValue[{mesh, 2}, MeshCellCentroid]];

IGRandomSpanningTree[g, VertexCoordinates -> GraphEmbedding[g],
 VertexShape -> None,
 EdgeStyle -> Directive[Orange, CapForm["Round"]],
 EdgeShapeFunction -> (Tube[Line[#1], 0.04] &)
 ]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Just nitpicking: I'd congratulate you if you would have found a truly hexagonal tiling on a sphere! (Also, I see pentagons there.) Although discretization doesn't really guarantee it, this looks like a maze over edges of a Goldberg polyhedron... $\endgroup$ – kirma Apr 29 '18 at 6:42
  • 1
    $\begingroup$ Nice work thank you! $\endgroup$ – R Hall Apr 30 '18 at 12:38
  • $\begingroup$ @kirma Of course, you are right. I posted in a rush. I corrected the phrasing now. $\endgroup$ – Szabolcs Apr 30 '18 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.