({{, (RefLink[CantorMesh, paclet:ref/CantorMesh])[n] 
gives a mesh region representing the n(^th)-step Cantor set. }, {, (RefLink[CantorMesh, paclet:ref/CantorMesh])[n,d]
gives the n(^th)-step Cantor set in dimension d.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[CantorMesh, paclet:ref/CantorMesh]) is also known as Cantor dust.

(RefLink[CantorMesh, paclet:ref/CantorMesh])[n] is generated from the unit interval by repeatedly removing the middle third of the subsequent cells.  »

(RefLink[CantorMesh, paclet:ref/CantorMesh])[n] is equivalent to (RefLink[CantorMesh, paclet:ref/CantorMesh])[n,1].

(RefLink[CantorMesh, paclet:ref/CantorMesh]) has the same options as (RefLink[MeshRegion, paclet:ref/MeshRegion]), with the following additions:

OpenersPrimaryExamplesSection(Spacer1)Examples  (28)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

A 1D Cantor mesh:

CantorMesh[2]

Lengths of the approximations to the Cantor mesh:

Table[RegionMeasure[CantorMesh[n]],{n,5}]//Rationalize

The formula:

FindSequenceFunction[%,n]

A 2D Cantor mesh:

CantorMesh[1,2]

A 3D Cantor mesh:

CantorMesh[1,3]

OpenersExampleSection1(Spacer1)Scope  (4)

A 1D Cantor mesh:

CantorMesh[2]

A 2D Cantor mesh:

CantorMesh[2,2]

A 3D Cantor mesh:

CantorMesh[2,3]

The n(^th) approximation to the Cantor set:

Table[CantorMesh[n],{n,0,5}]//Column

OpenersExampleSection2(Spacer1)Options  (13)

OpenersExampleSubsection0(Spacer1)DataRange  (1)

(RefLink[DataRange, paclet:ref/DataRange]) allows you to specify the range of mesh coordinates to generate:

CantorMesh[1,2]

RegionBounds[%]

Specify a different range:

CantorMesh[1,2,DataRange->{{0,1},{0,2}}]

RegionBounds[%]

OpenersExampleSubsection1(Spacer1)MeshCellHighlight  (2)

(RefLink[MeshCellHighlight, paclet:ref/MeshCellHighlight]) allows you to specify highlighting for parts of a (RefLink[CantorMesh, paclet:ref/CantorMesh]):

CantorMesh[0,2,MeshCellHighlight->{{1,All}->Red,{0,All}->Black}]

Individual cells can be highlighted using their cell index:

CantorMesh[0,2,MeshCellHighlight->{{1,2}->{Thick,Red},{1,3}->{Dashed,Black}}]

Or by the cell itself:

CantorMesh[0,2,MeshCellHighlight->{Line[{3,4}]->{Thick,Red},Line[{2,4}]->{Dashed,Black}}]

OpenersExampleSubsection2(Spacer1)MeshCellLabel  (2)

(RefLink[MeshCellLabel, paclet:ref/MeshCellLabel]) can be used to label parts of a (RefLink[CantorMesh, paclet:ref/CantorMesh]):

CantorMesh[0,2,MeshCellLabel->{0->"Index"}]

Individual cells can be labeled using their cell index:

CantorMesh[0,2,MeshCellLabel->{{1,1}->"x",{1,2}->"y"}]

Or by the cell itself:

CantorMesh[0,2,MeshCellLabel->{Line[{1,3}]->"x",Line[{3,4}]->"y"}]

OpenersExampleSubsection3(Spacer1)MeshCellMarker  (1)

(RefLink[MeshCellMarker, paclet:ref/MeshCellMarker]) can be used to assign values to parts of a (RefLink[CantorMesh, paclet:ref/CantorMesh]):

CantorMesh[0,2,MeshCellMarker->{{0,1}->1,{0,2}->2,{0,3}->3,{0,4}->4}]

Use (RefLink[MeshCellLabel, paclet:ref/MeshCellLabel]) to show the markers:

CantorMesh[0,2,MeshCellMarker->{{0,1}->1,{0,2}->2,{0,3}->3,{0,4}->4},MeshCellLabel->{0->"Marker"}]

OpenersExampleSubsection4(Spacer1)MeshCellShapeFunction  (2)

(RefLink[MeshCellShapeFunction, paclet:ref/MeshCellShapeFunction]) can be used to assign values to parts of a (RefLink[CantorMesh, paclet:ref/CantorMesh]):

CantorMesh[0,3,MeshCellShapeFunction->{1->(Tube[#1,.1]&)}]

Individual cells can be drawn using their cell index:

CantorMesh[0,3,MeshCellShapeFunction->{{1,2}->(Tube[#1,.1]&)}]

Or by the cell itself:

CantorMesh[0,3,MeshCellShapeFunction->{Line[{5,7}]->(Tube[#1,.1]&)}]

OpenersExampleSubsection5(Spacer1)MeshCellStyle  (3)

(RefLink[MeshCellStyle, paclet:ref/MeshCellStyle]) allows you to specify styling for parts of a (RefLink[CantorMesh, paclet:ref/CantorMesh]):

CantorMesh[0,2,MeshCellStyle->{{1,All}->Red,{0,All}->Black}]

Individual cells can be highlighted using their cell index:

CantorMesh[0,2,MeshCellStyle->{{1,1}->{Thick,Red},{1,2}->{Dashed,Black}}]

Or by the cell itself:

CantorMesh[0,2,MeshCellStyle->{Line[{1,3}]->{Thick,Red},Line[{3,4}]->{Dashed,Black}}]

Give explicit color directives to specify colors for individual cells:

CantorMesh[1,2,MeshCellStyle->{{2,All}->Black,{2,1}->Red,{2,{2,3}}->Pink}]

OpenersExampleSubsection6(Spacer1)PlotTheme  (2)

Use a theme with grid lines and a legend:

CantorMesh[1,2,PlotTheme->"Detailed"]

Use a theme to draw a wireframe:

CantorMesh[1,2,PlotTheme->"Lines"]

OpenersExampleSection3(Spacer1)Applications  (4)

The Cantor set is generated from the unit interval by repeatedly removing the middle third of the cells:

Column[{CantorMesh[0],CantorMesh[1],CantorMesh[2],CantorMesh[3]}]

In 2D:

Row[{CantorMesh[0,2],CantorMesh[1,2],CantorMesh[2,2]},Spacer[60]]

In 3D:

Row[{CantorMesh[0,3],CantorMesh[1,3],CantorMesh[2,3]},Spacer[60]]

Find the length of the Cantor mesh:

Table[RegionMeasure[CantorMesh[k]],{k,5}]//Rationalize

The general formula:

FindSequenceFunction[%,n]

Find the measure of the 2D Cantor mesh:

Table[RegionMeasure[CantorMesh[k,2]],{k,5}]//Rationalize

The general formula:

FindSequenceFunction[%,n]

Find the measure of the 3D Cantor mesh:

Table[{k,RegionMeasure[CantorMesh[k,3]]},{k,0,3}]//Rationalize

The general formula:

FindSequenceFunction[%,n]

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

The output of (RefLink[CantorMesh, paclet:ref/CantorMesh]) is always a full-dimensional (RefLink[MeshRegion, paclet:ref/MeshRegion]):

CantorMesh[3,2]

{MeshRegionQ[%],RegionDimension[%]}

(RefLink[CantorMesh, paclet:ref/CantorMesh]) consists of intervals in 1D:

CantorMesh[2]

MeshCells[%,RegionDimension[%]]

Rectangles in 2D:

CantorMesh[1,2]

MeshCells[%,RegionDimension[%]]

Hexahedrons in 3D:

CantorMesh[0,3]

MeshCells[%,RegionDimension[%]]

The total length removed of the Cantor set is 1:

Table[RegionMeasure[CantorMesh[n]]/2,{n,5}]//Rationalize

Guess the general formula:

FindSequenceFunction[%,i]

Limit[Sum[%,{i,1,n}],n->Infinity]

(RefLink[DataRange, paclet:ref/DataRange])->range is equivalent to using (RefLink[RescalingTransform, paclet:ref/RescalingTransform])[{…},range]:

CantorMesh[1,2,DataRange->{{1,2},{1,3}},Frame->True]

Use (RefLink[RescalingTransform, paclet:ref/RescalingTransform]):

box =TransformedRegion[CantorMesh[1,2],RescalingTransform[{{0,1},{0,1}},{{1,2},{1,3}}]];

MeshRegion[box,Frame->True]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[CantorMesh, paclet:ref/CantorMesh]) can be too large to generate:

CantorMesh[20,3]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CantorStaircase, paclet:ref/CantorStaircase])  ▪  (RefLink[SierpinskiMesh, paclet:ref/SierpinskiMesh])  ▪  (RefLink[ArrayMesh, paclet:ref/ArrayMesh])  ▪  (RefLink[MeshRegion, paclet:ref/MeshRegion])  ▪  (RefLink[BoundaryMeshRegion, paclet:ref/BoundaryMeshRegion])  ▪  (RefLink[KaryTree, paclet:ref/KaryTree])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Iterated Maps & Fractals, paclet:guide/IteratedMapsAndFractals])}, {▪(RefLinkPlain[Mesh-Based Geometric Regions, paclet:guide/MeshRegions])}})}})