boxes2.mws

MathClass Lesson 1:

Blocks and Bricks

Section 2: Translating Geometric Objects

The following commands, which we have copied from the previous section contain essentially everything we have done to this point to create our cube(s). In this chapter we will begin to make use of the colon ":" terminator for commands to suppress unwanted output. Note that the colon can always be replaced by a semicolon and the command re-executed if we need to look at the output .

> v1:=[1,0,1]:
v2:=[1,1,1]:
v3:=[1,1,0]:
v4:=[1,0,0]:
v5:=[0,0,1]:
v6:=[0,1,1]:
v7:=[0,1,0]:
v8:=[0,0,0]:

> front:=[v1,v2,v3,v4];
back:=[v5,v6,v7,v8];
left:=[v4,v8,v5,v1];
right:=[v3,v2,v6,v7];
bottom:=[v3,v4,v8,v7];
top:=[v1,v2,v6,v5];

front := [[1, 0, 1], [1, 1, 1], [1, 1, 0], [1, 0, 0...

back := [[0, 0, 1], [0, 1, 1], [0, 1, 0], [0, 0, 0]...

left := [[1, 0, 0], [0, 0, 0], [0, 0, 1], [1, 0, 1]...

right := [[1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 1, 0...

bottom := [[1, 1, 0], [1, 0, 0], [0, 0, 0], [0, 1, ...

top := [[1, 0, 1], [1, 1, 1], [0, 1, 1], [0, 0, 1]]...

> box:=[top, bottom, right, left, front, back]:

> bluetop:=plots[polygonplot3d](top, style=patch,color = blue ):
redbottom:=plots[polygonplot3d](bottom, style=patch,color = red):
yellowsides:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

> cube1:=plots[display]([bluetop, redbottom, yellowsides]):
cube1;

[Maple Plot]

It is evident that simply by changing the assigned values of v1..v8 we can create images of different cubes. However, rather than doing exactly that we will make another copy in this sheet which we will modify so that our previously defined objects will continue to have the same meaning. This illustrates a parctice that is always good to follow. Copy and paste working code whenever possible ( as opposed to re-typing it which almost always introduces mistakes). Since only the precise symbols we have defined have current meaning a slight change creates entirely new symbols and relationships. For instance we may elect to change the names of the vertices to w1,...,w8 and simply add a "w" to each of the previously defined words. (The reader will suspect immediately see that this could get out of hand if we keep doing the same thing - we will soon learn a more systematic approach) .

> frontw:=[w1,w2,w3,w4];backw:=[w5,w6,w7,w8];leftw:=[w4,w8,w5,w1];rightw:=[w3,w2,w6,w7];bottomw:=[w3,w4,w8,w7];topw:=[w1,w2,w6,w5];

frontw := [w1, w2, w3, w4]

backw := [w5, w6, w7, w8]

leftw := [w4, w8, w5, w1]

rightw := [w3, w2, w6, w7]

bottomw := [w3, w4, w8, w7]

topw := [w1, w2, w6, w5]

Now we have a "template" for a second cube and need only assign values to the vertices w1...w8 as before. The question is which values to assign.

Let us assume we want to stack a duplicate of the first cube directly on top of it. To "lift" our first cube (which has height 1) straight up so that its base moves to the level of its top requires that the "z-coordinate" of each of its points be increased by exactly 1. That is if [a,b,c] is a point on the cube that that point moves to [a,b,c+1]. We don't need to explicitly move every point,
only the vertices. Moreover we note that with an obvious meaning for addition [a,b,c+1]=[a,b,c]+[0,0,1]. Maple understands this addition so, assuming that the vertex w1 is where v1 goes, w2 is where v2 goes, ..., etc. we can assign values to our vertices w1...w8 as follows:

> shift:=[0,0,1];

shift := [0, 0, 1]

> w1:=v1+shift;w2:=v2+shift;w3:=v3+shift;w4:=v4+shift;w5:=v5+shift;w6:=v6+shift;w7:=v7+shift;w8:=v8+shift;

w1 := [1, 0, 2]

w2 := [1, 1, 2]

w3 := [1, 1, 1]

w4 := [1, 0, 1]

w5 := [0, 0, 2]

w6 := [0, 1, 2]

w7 := [0, 1, 1]

w8 := [0, 0, 1]

> boxw:=[topw, bottomw, rightw, leftw, frontw, backw];

boxw := [[[1, 0, 2], [1, 1, 2], [0, 1, 2], [0, 0, 2...
boxw := [[[1, 0, 2], [1, 1, 2], [0, 1, 2], [0, 0, 2...

> bluetopw:=plots[polygonplot3d](topw, style=patch,color = blue ):
redbottomw:=plots[polygonplot3d](bottomw, style=patch,color = red):
yellowsidesw:=plots[polygonplot3d]([leftw,rightw,frontw,backw], style=patch,color = yellow):

Let's put in an origin to show the shift. Note a list with one point in it is a polygon.

> ORIGIN := plots[polygonplot3d]([[0,0,0]]):

> cube2:=plots[display]([ ORIGIN,bluetopw, redbottomw, yellowsidesw], axes=normal):
cube2;

[Maple Plot]

Reference to the axes (perhaps after rotating the 3D object with the mouse) verifies that our new cube is indeed a copy of the old one shifted up exactly one uint. The question now is how to display them at the same time. The answer is to use plots[display] just as before. Note that we could do as follows:

> twocubes:=plots[display]([ plots[display]([bluetop, redbottom, yellowsides]),plots[display]([bluetopw, redbottomw, yellowsidesw], axes=normal)] );

[Maple Plot]

However the following is easier and much simpler to read and understand

> twocubes:=plots[display](cube1,cube2):
twocubes;

>

[Maple Plot]

We haven't constrained the images so they don't look like cubes. Moreover, even though it isn't always necessary its a good idea to submit collections of plots to plots[display] as an ordered list:

> stackedcubes:=plots[display]([cube1, cube2], axes=normal, scaling=constrained):
stackedcubes;

[Maple Plot]

There is no reason to for both cubes the same color or style, we can give the faces of cube2 any color or style we want. What if we want a cube3? The obvious ways to produce a cube3 are repeat what we did to get cube2 or even to take the tack we avoided then and simply modify our previous code to produce a cube3. Keeping in mind that once we have produced cube2 if we then redefine the vertices w1..w8 we can produce a separate cube3, retaining the picture of our "original" cube2 but not cube2 itself. We could do the same thing to get a cube4, cube5, etc. If all we want are the pictures this will work but there are problems. For instance, suppose we wanted 100 cubes made them all yellow and then decided that they should be red. We would have to repeat all of these steps "by hand". Fortunately, Maple provides tools to automate this type of manufacturing process. What we need to do is build a new Maple word which takes the original cube and produces a set of "stacked" copies (or a picture of such a set) assembled according to our instructions. We will take up this process in the next chapter but first we want to actually build a few new cubes and assemble them in order to gain a firm grasp of exactly what process we want to automate. This will be a process we will repeat many times in this study. First let us block out what we did to get cube1.



The steps in building a cube

1. Define the original, abstract cube "box" as a list of faces where each face was itself a list of vertices v1..v8.

2. Assign specific values to the vertices v1..v8. Doing so automatically caused Maple to interpret the abstract cube, box, as the specific cube with the vertices assigned to v1..v8.

3. Execute a command "cube1:=plots[polygonplot3d](box, options)" which produced a plot structure representing the current "value" of "box "

Now let us extend these steps to the process which produced cube2 - but this time re-assigning the values of the v1..v8 rather than introducing the new vertices.

4. Assign a specific value to the word "shift" (note there is nothing special about the word "shift", "yzkotqp" would work just as well but would be less intuitive and perhaps harder to remember).

5. Assign new values to v1..v8 by the assignment commands v1:=v1+shift; v2:=v2+shift; ..., which say "the new value of v1 is the current value of v1 plus shift, etc.

6. Execute the command "cube2:=plots[polygonplot3d](box, options)"

7. go to step 4.

Building a TEE

Lets create an assemblage of cubes in the shape of a "T" as in the following sketch.

[Maple OLE 2.0 Object]

Although we don't really need to we will repeat the initial steps. This time we will use a different notation for the pictures of the faces which doesn't designate their colors so that we may feel free to vary these as we wish. In addition, we introduce the "shift" immediately and simply let it be [0,0,0] to start.

> v1:=[1,0,1]: v2:=[1,1,1]: v3:=[1,1,0]: v4:=[1,0,0]: v5:=[0,0,1]: v6:=[0,1,1]: v7:=[0,1,0]: v8:=[0,0,0]:

> shift:=[0,0,0]:

> v1:=v1+shift: v2:=v2+shift: v3:= v3+shift: v4:=v4+shift: v5:=v5+shift: v6:=v6+shift: v7:=v7+shift: v8:=v8+shift:
front:=[v1,v2,v3,v4]:back:=[v5,v6,v7,v8]:left:=[v4,v8,v5,v1]:right:=[v3,v2,v6,v7]:bottom:=[v3,v4,v8,v7]:top:=[v1,v2,v6,v5]:

> toppic:=plots[polygonplot3d](top, style=patch,color = blue ): bottompic:=plots[polygonplot3d](bottom, style=patch,
color = red):
sidespic:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

> cube1:=plots[display]([ toppic, bottompic, sidespic]):

Now we have cube1, all we need do now is reset the shift and repeat the second group of commands, changing only the name of the result to "cube2".

> v1:=[1,0,1]: v2:=[1,1,1]: v3:=[1,1,0]: v4:=[1,0,0]: v5:=[0,0,1]: v6:=[0,1,1]: v7:=[0,1,0]: v8:=[0,0,0]:

> shift:=[0,0,1]:

> v1:=v1+shift: v2:=v2+shift: v3:= v3+shift: v4:=v4+shift: v5:=v5+shift: v6:=v6+shift: v7:=v7+shift: v8:=v8+shift:
front:=[v1,v2,v3,v4]:back:=[v5,v6,v7,v8]:left:=[v4,v8,v5,v1]:right:=[v3,v2,v6,v7]:bottom:=[v3,v4,v8,v7]:top:=[v1,v2,v6,v5]:

> toppic:=plots[polygonplot3d](top, style=patch,color = blue ):
bottompic:=plots[polygonplot3d](bottom, style=patch,color = red):
sidespic:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

> cube2:=plots[display]([ toppic, bottompic, sidespic]):

Now cube3 results from a shift of two units straight up

> v1:=[1,0,1]: v2:=[1,1,1]: v3:=[1,1,0]: v4:=[1,0,0]: v5:=[0,0,1]: v6:=[0,1,1]: v7:=[0,1,0]: v8:=[0,0,0]:

> shift:=[0,0,2]:

> v1:=v1+shift: v2:=v2+shift: v3:= v3+shift: v4:=v4+shift: v5:=v5+shift: v6:=v6+shift: v7:=v7+shift: v8:=v8+shift:
front:=[v1,v2,v3,v4]:back:=[v5,v6,v7,v8]:left:=[v4,v8,v5,v1]:right:=[v3,v2,v6,v7]:bottom:=[v3,v4,v8,v7]:top:=[v1,v2,v6,v5]:

> toppic:=plots[polygonplot3d](top, style=patch,color = blue ):
bottompic:=plots[polygonplot3d](bottom, style=patch,color = red):
sidespic:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

>

> cube3:=plots[display]([ toppic, bottompic, sidespic]):

Cube4 is two up and one to the "right"

> v1:=[1,0,1]: v2:=[1,1,1]: v3:=[1,1,0]: v4:=[1,0,0]: v5:=[0,0,1]: v6:=[0,1,1]: v7:=[0,1,0]: v8:=[0,0,0]:

> shift:=[-1,0,2]:

> v1:=v1+shift: v2:=v2+shift: v3:= v3+shift: v4:=v4+shift: v5:=v5+shift: v6:=v6+shift: v7:=v7+shift: v8:=v8+shift:
front:=[v1,v2,v3,v4]:back:=[v5,v6,v7,v8]:left:=[v4,v8,v5,v1]:right:=[v3,v2,v6,v7]:bottom:=[v3,v4,v8,v7]:top:=[v1,v2,v6,v5]:

> toppic:=plots[polygonplot3d](top, style=patch,color = blue ):
bottompic:=plots[polygonplot3d](bottom, style=patch,color = red):
sidespic:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

>

> cube4:=plots[display]([ toppic, bottompic, sidespic]):

And cube5 results from a shift of two up and one to the "left"

>

> v1:=[1,0,1]: v2:=[1,1,1]: v3:=[1,1,0]: v4:=[1,0,0]: v5:=[0,0,1]: v6:=[0,1,1]: v7:=[0,1,0]: v8:=[0,0,0]:

> shift:=[1,0,2]:

> v1:=v1+shift: v2:=v2+shift: v3:= v3+shift: v4:=v4+shift: v5:=v5+shift: v6:=v6+shift: v7:=v7+shift: v8:=v8+shift:
front:=[v1,v2,v3,v4]:back:=[v5,v6,v7,v8]:left:=[v4,v8,v5,v1]:right:=[v3,v2,v6,v7]:bottom:=[v3,v4,v8,v7]:top:=[v1,v2,v6,v5]:

> toppic:=plots[polygonplot3d](top, style=patch,color = blue ):
bottompic:=plots[polygonplot3d](bottom, style=patch,color = red):
sidespic:=plots[polygonplot3d]([left,right,front,back], style=patch,color = yellow):

>

> cube5:=plots[display]([ toppic, bottompic, sidespic]):

We have not taken the time to change the colors on our various cubes but we could have, simply by changing the options for each of them. Lets make our cubes into a list and display them

> cubes:=[cube1,cube2,cube3,cube4,cube5]:

Finally, we can display our cubes. Since its to be a "T" we'll call it "Tee". The following command will then assign that plot structure to the symbol "Tee". It will not display it. On the other hand, Tee then becomes a Maple word whose value is that plot structure so when Maple receives "Tee" from the command line it will respond return "Tee" in the manner it represents such structures - namely by plotting them.

> Tee:=plots[display](cubes, scaling=constrained):

> Tee;

[Maple Plot]

Exercise: Change the "T" into a "+" sign.

Exercise: Change the "T" so that its two "T" faces are different colors and the "edge" is a the same color all around (but different from the colors of the two sides).

Exercise: Create the letters "M", "A" and "H" to go with the "T"

>

Exercise: The "T" generated previously is an example of a figure that can be made by five identical cubes such that each of them share a face with at least one other. There is an "L" figure which can be made with 4. Find all of the figures of this type which can be made using either three or four cubes and construct a Maple word for each one which displays it. We regard two figures as the same if they are congruent in the sense of geometry - that is if one could be moved and rotated in space to become coincident with the other. Include a careful explanation of why your list is complete.