Wolfram 언어

주요 기하학적 기능

배열로부터의 메쉬

버전 11에서는 컬러 테트로미노의 생성 및 패턴에서 체스판 또는 임의의 기하학적 형상의 구축을 간단히 해결할 수 있습니다.

In[1]:=
Click for copyable input
arrays = {\!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "0", "0", "0"}, {"1", "0", "0", "0"}, {"1", "0", "0", "0"}, {"1", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "1", "0", "0"}, {"0", "1", "0", "0"}, {"0", "1", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "1", "0", "0"}, {"1", "0", "0", "0"}, {"1", "0", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"0", "1", "0", "0"}, {"1", "1", "0", "0"}, {"0", "1", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "0", "0", "0"}, {"1", "1", "0", "0"}, {"0", "1", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "1", "0", "0"}, {"1", "1", "0", "0"}, {"0", "0", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"1", "1", "0", "0"}, {"0", "1", "1", "0"}, {"0", "0", "0", "0"}, {"0", "0", "0", "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)};
In[2]:=
Click for copyable input
col = ColorData[97, "ColorList"];
In[3]:=
Click for copyable input
Table[ArrayMesh[arrays[[i]], MeshCellStyle -> {2 -> col[[i]]}], {i, 7}]
Out[3]=

3D 체스판을 구축합니다.

In[4]:=
Click for copyable input
m = Join @@ ConstantArray[{{{0}, {1}, {0}, {1}, {0}, {1}, {0}, {1}}, {{1}, \ {0}, {1}, {0}, {1}, {0}, {1}, {0}}}, 4];
In[5]:=
Click for copyable input
p = First /@ Position[Flatten[m], 1];
In[6]:=
Click for copyable input
style = {{1, All} -> {Thick, Black}, {3, All} -> White, {3, #} & /@ p -> Black};
In[7]:=
Click for copyable input
r = ArrayMesh[ConstantArray[1, {8, 8, 1}], MeshCellStyle -> style]
Out[7]=

서로 교차하지 않는 터널이 모든 방향에 위치해 있는 영역 자이델 메쉬를 구축합니다.

전체 Wolfram 언어 입력 표시하기
In[8]:=
Click for copyable input
seidelArray[{r_, s_, t_}] := Table[If[Mod[i, 4] == 2 && Mod[j, 4] == 2 || Mod[i, 4] == 0 && Mod[k, 4] == 0 || Mod[j, 4] == 0 && Mod[k, 4] == 2, 0, 1], {i, 3 + r 4}, {j, 3 + s 4}, {k, 3 + t 4}] transparentMesh[mr_?MeshRegionQ] := HighlightMesh[ BoundaryMesh[mr], {Style[1, None], Style[2, Opacity[0.5]]}]
In[9]:=
Click for copyable input
transparentMesh[ArrayMesh[seidelArray[{2, 2, 2}]]]
Out[9]=

콘웨이의 라이프 게임을 구현합니다.

In[10]:=
Click for copyable input
gameOfLife = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}; board = RandomInteger[1, {40, 40}];
In[11]:=
Click for copyable input
sim = NestList[Last[CellularAutomaton[gameOfLife, #, {{0, 1}}]] &, board, 70];
In[12]:=
Click for copyable input
ListAnimate[ArrayMesh /@ sim]
Out[12]=
애니메이션 작동
애니메이션 정지

관련 예제

de en es fr ja pt-br ru zh