MCS 320 Project Two due Friday 11 November 2005
| > | restart; |
Some of the plotting commands are only for illustration purposes and have been commented out.
The arguments of the command read only list the file name and work when Maple on linux is launched from within the working directory. On other platforms, the complete path name to locate the file will have to be specified.
1. Sierpinski's Curves
A triangle is plotted by the command polygonplot:
| > | v := [[0,0],[1,0],[0,1]]: # vertices of the triangle |
With style = line, polygonplot only draws the edges of the triangle. If this option is omitted, the triangle is considered as solid. In this case, we may change the default white color into green with the option color = green. This is illustrated below:
| > | # plots[polygonplot](v,style=line,axes=none); |
| > | # plots[polygonplot](v,color=green,axes=none); |
The procedure gasket below plots part of Sierpinski's triangular curve, also known as the Sierpinski gasket.
The arguments of gasket are
a is the first coordinate of the leftmost corner of the triangle;
b is the second coordinate of the leftmost corner of the triangle;
L is the length of the horizontal and vertical sides of the triangle;
k is a counter, it typically equals 0 when the user calls gasket;
m is the depth of the tree of recursive calls.
The triangle is divided into four similar triangles. The central triangle is taken out. The removal of the central triangle is repeated on the other three remaining triangles. As this process goes on recursively for ever, it is not too difficult to show that the area of the removed triangles equals the area of the entire triangle. Therefore, what remains has area equal to zero and counts as a curve.
| > | read("gasket.mpl"); |
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
A typical use of the procedure goes as follows:
| > | p := gasket(0,0,1,0,2): |
| > | plots[display](p,axes=none); |
![[Plot]](images/proj2_18.gif)
Assignment One
The goal of this assignment is to write a Maple procedure to plot Sierpienski's rectangular curve, also known as the Sierpinski carpet.
Sierpinski's rectangular curve starts by dividing a rectangle (we will take a square) into nine similar rectangles. The central rectangle is removed. The removal process is applied to the eight remaining rectangles.
| > | read("carpet.mpl"): |
| > | op(1,eval(carpet)); |
The parameters of the procedure carpet have the same meaning as in the procedure gasket. The coordinates of the leftmost corner of the carpet are given by [a,b], L is the lengthe of each side. The parameter k controls the depth of the recursion tree, and should be initially equal to zero. The maximal depth of the recursion tree is given by m.
| > | p := carpet(0,0,1,0,2): |
| > | plots[display](p,axes=none); |
![[Plot]](images/proj2_20.gif)
2. The Menger Sponge
There is a three dimensional analogue to the Spierpinski gasket, the so-called Menger sponge. The elementary command from plottools we use is hexahedron, e.g.:
| > | hx := plottools[hexahedron]([0,0,0],1): |
defines a cube centered at the origin [0,0,0] with sides of length 2 for all directions. The following command illustrates the definition:
| > | # plots[display](hx,axes=boxed); |
The Menger sponge is obtained by taking a cube and "drilling through" the center of each face. As the cube has six faces, we omit from the big cube seven smaller cube whose sides are one third of the original length.
Assignment Two
A first method to plot the Menger sponge proceeds in the same fashion as with the Sierpinski carpet: we plot the cubes omitted from the original cube.
| > | read("sponge.mpl"): |
| > | op(1,eval(sponge)); |
The procedure sponge has six parameters: a,b,c,L,v, and m.
The center of the cube is defined by the first three parameters: a,b,c.
The length of the first cube is L. The parameter v is a counter, used to control the level of recursion in the tree and initially called as 0. The m is the maximal depth of the recursion tree.
Following are some examples:
| > | p0 := sponge(0,0,0,1,0,0): |
| > | plots[display](p0); |
![[Plot]](images/proj2_22.gif)
| > | p1 := sponge(0,0,0,1,0,1): |
| > | plots[display](p1); |
![[Plot]](images/proj2_23.gif)
Provide an implementation for the procedure sponge.
Assignment Three
A second method to plot the Menger sponge is to plot what remains after drilling the holes in the cube.
The elementary plotting command we use is
| > | p := plottools[cutout](plottools[hexahedron]([0,0,0],1),0.4): |
| > | # plots[display](p); |
The plot shows the cube centered at [0,0,0], all slides have length 2, and their area is reduced by 40%.
This reduction factor is an additional parameter in the procedure menger:
| > | read("menger.mpl"): |
| > | op(1,eval(menger)); |
The reduction factor is an additional parameter in the procedure menger, as fifth parameter f, occurring after the length L and before the parameter v which controls the recursion level. Some examples:
| > | p1 := menger(0,0,0,1,0.4,0,1): plots[display](p1); |
![[Plot]](images/proj2_25.gif)
| > | p2 := menger(0,0,0,1,0.4,0,2): plots[display](p2); |
![[Plot]](images/proj2_26.gif)
Provide an implementation for the procedure menger.
3. Dimension Calculations
The Sierpinski gasket is a curve because the area of what we remove from the triangle equals the area of the entire triangle. So the area of the Sierpinski gasket is zero, when we call it a curve. The purpose of the next assignment is to validate this statement.
Assignment Four
Use Maple to show that the Sierpinski gasket and carpet have zero area.
To show that the area is zero, add up the area of all the pieces which are removed from the Sierpinski curves, gasket and carpet, and show that the area of the removed pieces sums up to the area of the respective original triangle and rectangle. Use Maple's sum command for this.
Also show that the volume of the Menger sponge equals zero, using the same method.
4. The deadline if Friday 11 November 2005, at 2PM
Bring a print out of the Maple worksheet to class. Also eMail me the (only one!) worksheet as an attachment.
Feel free to come to my office for help.