MengerMesh

MengerMesh[n]

gives a mesh region representing the n^(th)-step Menger sponge.

MengerMesh[n,d]

gives the n^(th)-step Menger sponge in dimension d.

Details and Options

Examples

open allclose all

Basic Examples  (2)

A 2D Menger mesh:

Areas of the approximations to the Menger mesh:

The formula:

A 3D Menger mesh:

Scope  (3)

A 2D Menger mesh:

A 3D Menger mesh:

The n^(th) approximation of the Menger mesh:

Options  (12)

DataRange  (1)

DataRange allows you to specify the range of mesh coordinates to generate:

Specify a different range:

MeshCellHighlight  (2)

MeshCellHighlight allows you to specify highlighting for parts of a MengerMesh:

Individual cells can be highlighted using their cell indices:

Or by the cell itself:

MeshCellLabel  (2)

MeshCellLabel can be used to label parts of a MengerMesh:

Individual cells can be labeled using their cell indices:

Or by the cell itself:

MeshCellMarker  (1)

MeshCellMarker can be used to assign values to parts of a MengerMesh:

Use MeshCellLabel to show the markers:

MeshCellShapeFunction  (2)

MeshCellShapeFunction can be used to assign values to parts of a MengerMesh:

Individual cells can be drawn using their cell indices:

Or by the cell itself:

MeshCellStyle  (2)

MeshCellStyle allows you to specify styling for parts of a MengerMesh:

Individual cells can be highlighted using their cell indices:

Or by the cell itself:

PlotTheme  (2)

Use a theme with grid lines and a legend:

Use a theme to draw a wireframe:

Applications  (1)

The Menger mesh is generated from a unit square by repeatedly removing the middle square of the cells:

In 3D:

Properties & Relations  (7)

The output of MengerMesh is always a full-dimensional MeshRegion:

MengerMesh consists of rectangles in 2D:

Hexahedrons in 3D:

Find the area of the Menger mesh in 2D at each stage:

Guess the general formula:

Find the volume of the Menger mesh in 3D at each stage:

Each face of the MengerMesh in 3D (Menger sponge) is a MengerMesh in 2D (Sierpiński carpet):

Get 3D coordinates and faces:

Get 2D coordinates and faces:

Find the boundary mesh region of MengerMesh:

DataRange->range is equivalent to using RescalingTransform[{...},range]:

Use RescalingTransform:

Possible Issues  (1)

MengerMesh can be too large to generate:

Introduced in 2017
 (11.1)