A 3-unit Menger sponge contains 27 cells (3x3x3). This gives 2^27 = 134217728 possible recursive patterns (too many).

Now if we only want symmetric structures (under the symmetry group for the cube), there are only four different types of cells in the sponge, which we can label according to their distance from the center cube:

Distance 0: the cube center cell

Distance 1: the 6 side center cells

Distance 2: the 12 cells two steps away.

Distance 3: the 8 corner cells.

Now, this means there are only 16 (2^4) different symmetric unit-3
menger sponges.

Labeling these from 0-15 (using the distances above as base-2 bases)
gives a natural enumeration. The original Menger cube ((lower left
corner) is number 12 with this enumeration (It uses Distance 2 and 3
patterns = 1100 in binary) .

The 16 possible Mengers are depicted above. They are drawn to level 2 (a maximum of 9x9x9=729 cells), but the recursion level may be increased in the code below.

The EisenScript is below (notice that the preprocessor commands require a version of Structure Synth from SVN (post 0.8.5) - so this will not work with the current binary releases). The recursion level may be changed using the 'maxdepth' parameter:

// ---- Set the bit pattern of the Menger enumeration here.

#define DISTANCE0 OFF

#define DISTANCE1 OFF

#define DISTANCE2 ON

#define DISTANCE3 OFF

#define WIDTH 0.05

#define STEP 10

// Camera settings. Place these before first rule call.

set translation [0.566876 -3.52063 -20]

set rotation [0.596494 -0.797386 0.0913825 0.253351 0.295103 0.921269
-0.761576 -0.526383 0.378044]

set pivot [0 0 0]

set scale 5.35875

set background #fff

ON

rule ON maxdepth 1 > MyBox {

{ s 1/3 } DISTANCE0

{ s 1/3 x -1 } DISTANCE1

{ s 1/3 x +1 } DISTANCE1

{ s 1/3 y -1 } DISTANCE1

{ s 1/3 y +1 } DISTANCE1

{ s 1/3 z -1 } DISTANCE1

{ s 1/3 z +1 } DISTANCE1

{ s 1/3 x -1 y -1 } DISTANCE2

{ s 1/3 x 1 y -1 } DISTANCE2

{ s 1/3 y -1 z -1 } DISTANCE2

{ s 1/3 y -1 z +1 } DISTANCE2

{ s 1/3 x -1 y 1 } DISTANCE2

{ s 1/3 x 1 y 1 } DISTANCE2

{ s 1/3 y 1 z -1 } DISTANCE2

{ s 1/3 y 1 z +1 } DISTANCE2

{ s 1/3 x -1 z -1 } DISTANCE2

{ s 1/3 x -1 z +1 } DISTANCE2

{ s 1/3 x 1 z -1 } DISTANCE2

{ s 1/3 x 1 z +1 } DISTANCE2

{ s 1/3 x 1 y -1 z -1 } DISTANCE3

{ s 1/3 x -1 y -1 z -1} DISTANCE3

{ s 1/3 x -1 y -1 z +1} DISTANCE3

{ s 1/3 x 1 y -1 z +1 } DISTANCE3

{ s 1/3 x -1 y 1 z -1 } DISTANCE3

{ s 1/3 x -1 y 1 z +1 } DISTANCE3

{ s 1/3 x 1 y 1 z -1 } DISTANCE3

{ s 1/3 x 1 y 1 z +1 } DISTANCE3

}

// ---- All this below is just to improve the visual style. A single box would do the job

rule MyBox {

{ s 0.9 color white } box

{ color black } frame

}

rule frame {

{ s WIDTH 1 WIDTH x STEP z STEP } box

{ s WIDTH 1 WIDTH x STEP z -STEP } box

{ s WIDTH 1 WIDTH x -STEP z STEP } box

{ s WIDTH 1 WIDTH x -STEP z -STEP } box

{ s 1 WIDTH WIDTH y STEP z STEP } box

{ s 1 WIDTH WIDTH y STEP z -STEP } box

{ s 1 WIDTH WIDTH y -STEP z STEP } box

{ s 1 WIDTH WIDTH y -STEP z -STEP } box

{ s WIDTH WIDTH 1 y STEP x STEP } box

{ s WIDTH WIDTH 1 y STEP x -STEP } box

{ s WIDTH WIDTH 1 y -STEP x STEP } box

{ s WIDTH WIDTH 1 y -STEP x -STEP } box

}

rule Off {

}

Ethan Hein, subblue, lennyjpg, roddh, and 4 other people added this photo to their favorites.

davebollinger ages ago | reply

interesting classification :)

noticing your notes... yeh, it's a shame the one-bit cube toggling is obscured in several cases. (and shame on your evil pun! ;D)

aside: another classification (tho less interesting, giving only 4 results) comes about if you define the menger pattern by the number of edges or axes (assuming you center the cube -1,0,1), where nedges < 2 or naxes > 1 defines the holes (or conversely, swap it around to define the solids). then whichever of those 4 rule variations you choose, substitute 0,1,2,3 as the limit, giving null,"dust","sponge","solid" as results. (#'s 0,8,12,15 here, i believe)

Syntopia ages ago | reply

Thanks!

Yes, I was inspired by your series of sponges - unfortunately I was too lazy to raytrace them.

The nice thing about this enumeration is that you get all possible symmetric 3-unit systems in a somewhat natural encoding. You can do the same for the 4-unit systems (again only 4 different cell types that are invariant under the octahedral symmetries, leading to 16 different forms - at least if we require symmetry under both reflection and rotation.)

So I hoped the enumeration would generalize to higher units. But it doesn't, making it slightly less interesting :-(

The enumeration scheme breaks down already for the 5-unit, which has 10 different cell types, but only 7 different distances (0-6 units away from the center cube). So there 1024 different symmetric 5-unit forms, but the distance enumeration scheme would only capture 128 of them. This can probably be salvaged, but already at 5 units there are too many forms to explore - and most of them are probably quite boring :-)

davebollinger ages ago | reply

Very cool.

I suppose you could "resolve" the distance conflicts with some arbitrary sequential winding scheme that enumerates through the cubes of equal distance? Maybe the path of a Hilbert curve, just to avoid complete arbitrariness?

Do you happen to know off the top of your head... if you eliminate the requirement for symmetry of the result, how many of the 2^27 combinations of the 3-unit are unique through symmetry? (that is,

notjust a rotation/reflection of another pattern) It's obviously a big number, but it would be an interesting set to enumerate as a technical experiment -- tho, again, probably a lot of them are boring visually ;)Syntopia ages ago | reply

Yes - I suppose an enumeration is possible (another possibility would be to look at distances for each layer - so for the 5-unit, you could label cells in terms of distances for the 1-unit, the 3-unit outer layer and the 5-unit outer layer - this might break down for higher units again, though).

I'm quite convinced that the number of unique 2-colorings of the 3-unit cube may be calculated using Burnside's Lemma.

My group theory is a bit rusty, but I might give it a try. It will be a large number - higher than (2^27)/24 I think the lemma tells us... (24 is the order of the symmetry group for the cube - not allowing reflections)

Syntopia ages ago | reply

Using Burnside for the 2-unit cube, there is:

1/24 ( 256 + 6*4 + 3*16 + 8*16 + 6*8 ) = 21 unique different patterns (out of the 256 possible coloring)

The similar Lemma for 3-units, will be of this form:

1/24 ( 2^27 + 6 * x + 3 * y + 8 *z + 6* w), meaning there are more than 5 million colorings!

Update - did the counting :

(1 / 24) * (1*2^27+6*2^9+3*2^15+8*2^11+6*2^15) = 5605504 unique patterns.

davebollinger ages ago | reply

ouch!! thanks for that :)

does that number still include reflections?

btw, i've enum'd the twos

Syntopia ages ago | reply

No, this number is only rotational symmetry.

Taken reflections into account should approximately halve this count - but I'm not going to calculate the exact figure :-)

roddh 113 months ago | reply

Nice use of DEFINEs to create a higher level pattern language.