#!/usr/bin/env python3
+
+# Plot a Menger sponge.
#
-# Copyright 2014 MINES ParisTech
-#
-# This file is part of LinPy.
-#
-# LinPy is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# LinPy is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# The construction of a Menger sponge can be described as follows:
#
-# You should have received a copy of the GNU General Public License
-# along with LinPy. If not, see <http://www.gnu.org/licenses/>.
+# 1. Begin with a cube.
+# 2. Divide every face of the cube into 9 squares, like a Rubik's Cube. This
+# will sub-divide the cube into 27 smaller cubes.
+# 3. Remove the smaller cube in the middle of each face, and remove the smaller
+# cube in the very center of the larger cube, leaving 20 smaller cubes. This
+# is a level-1 Menger sponge (resembling a Void Cube).
+# 4. Repeat steps 2 and 3 for each of the remaining smaller cubes, and continue
+# to iterate.
import argparse
from linpy import *
+
x, y, z = symbols('x y z')
_x, _y, _z = x.asdummy(), y.asdummy(), z.asdummy()
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Compute a Menger sponge.')
- parser.add_argument('-n', '--iterations', type=int, default=1,
- help='number of iterations (default: 1)')
+ parser.add_argument('-n', '--iterations', type=int, default=2,
+ help='number of iterations (default: 2)')
parser.add_argument('-c', '--cut', action='store_true', default=False,
help='cut the sponge')
args = parser.parse_args()