Stephan's Project 11
Skip to end of metadata
Go to start of metadata

Stephan Chaikovsky

5.8.15

CS151A

Project 11: 3d Scenes

Summary: For this project I added five 3d shapes to my shapes.py file, and created a "cityscene" function in shapes.py that draws a city skyline using these shapes. The four shapes I created for the first part of this project are Box, Prism, House, and PentPrism. For part 3 of this project, I designed a class that creates dodecahedron objects.

Summary of Files:

shapes.py: I added five 3d shapes to my shapes.py file, and created a "cityscene" function within the file.

3d Shapes in shapes.py:

Box: This class draws 3d box objects based on the width, height and depth provided in parameters. In the _init_ method, the string that will draw the box is built from a 3 substrings, b, m, and f (back, middle and front). b represents the back of the box, m represents one of the links between the back and front of the box, and f represents the front of the box as well as the remaining links to the back.

Prism: This class draws 3d triangular prism objects based on the sidelength and depth provided in parameters. In the _init_ method, the string that will draw the prism is built from a 3 substrings, b, m, and f (back, middle and front). b represents the back of the prism (a triangle), m represents one of the links between the back and front of the prism, and f represents the front of the prism as well as the remaining links to the back.

House: This class draws 3d house objects based on the side length and height provided in parameters (the height controls the height of the box portion of the house. In the _init_ method, the string that will draw the box is built from a 6 substrings, which represent the back, middle, and front of both the box and the triangular prism that the house consists of.

pentPrism: This class draws 3d pentagonal prism objects based on the sidelength and depth provided in parameters. In the _init_ method, the string that will draw the prism is built from a 3 substrings, b, m, and f (back, middle and front). b represents the back of the prism (a pentagon), m represents one of the links between the back and front of the prism, and f represents the front of the prism as well as the remaining links to the back.

Required Image 1 (shapes drawn using at least 2 styles):

cityScene function: I created a function that uses these shapes to draw a city skyline. In designing this scene, I made sure that the buildings were properly lined up with one another, as if they were lining a street. From there, I tried to be creative with the shapes I could work with to make interesting buildings with features towers and antennas.

Required Images 2/3 (cityScene from different perspectives):

dodecahedron (class): For part three of this project, I created a class that draws dodecahedrons based on a side length parameter. My #1 priority was to do this as efficiently as possible. Because of this, I created a string that would form 1 half of the dodecahedron when called 5 times, and a string that would reorient the turtle to draw the other half of the shape. I stored the dihedral angle of the shape (which I found on wikipedia) as a variable that I used in the strings to control the various orientation parameters. Even with the line of code storing the dihedral angle, the _init_ method of this class only contains four lines; one to store the angle, one to create the base string, one to create the reorientation string, and one that calls the parent init method and builds the string properly.

Required Image 4 (my dodecahedron):

Extensions: Other than the dodecahedron class I did not complete any extensions, but I did put a lot of effort into creating that class in the most efficient way possible.

What I learned: How to use the 3d Turtle and create 3d shapes.

Outside sources:

Wikipedia ("Dodecahedron")- to find the dihedral angle of a dodecahedron

Otherwise, no outside help.

Labels