The task this week was to use the 3D turtle to create three dimensional objects. The next part of the project was to use these three dimensional shapes to create a three dimensional scene and then to pick an extension and create a solution to it.
The first task in this project was to create four three dimensional shape classes that use strings to draw three dimensional objects. For this part of the project, along with the three dimensional cube given to us in lecture, I made a pyramid, triangular prism, diamond, and a table shaped object. I was able to create these objects through my own thoughts and ideas of the 3D turtle and some guidance from working with Stephanie and Jess Rosenberg in the CS lab office hours. For each of these shapes, I first created a shape class under my shapes.py file for each individual shape. Each shape class contained functions with differing parameters. It also contained the strings that was used to draw the object. The strings were interpreted character by character using my interpreter.py file. I then created a threeDshapes.py file that called the string by importing my shapes.py file. The threeDshapes.py file also gave the command to execute the draw function at a determined position. Also in the threeDshapes.py file, I used the jitter line type to mix up the drawing style of a couple of my shapes.The shapes that I created are below.
The second task for this project was to create a scene using my three dimensional shapes. I decided to make a snow scene featuring a snowman made out of three dimensional blocks. To do this, I started by making a threeDscene.py file. In this file, I defined a main function that contained my entire scene. Under the function was all the variable assignments that called back each class under my shapes.py file. After making these assignment, I set the width and color of my shapes and finally used the draw function to draw the shape at the specified location. I called the block function three different times at locations at different sizes to create the skeleton of the snowman. I then gave the snowman eyes, a mouth, and buttons by again using my block function, calling back to my cube class in my shapes file, looping through and drawing each item in the loop. I used my pyramid shape from my shapes.py file to make the snowman's nose. I made the color of the nose orange so it resembled a carrot. For the nose, eyes, mouth, and buttons, I made their z-positions in line with the front face of the box so it looked like they were on the outside of snowman but still connected rather than floating in space. Finally, I added snow to my scene. I decided to make three different snow locations, shapes, and for loops. I used my cube, diamond, and triangular prism shapes for the snow. I created a list of three colors called snow_colors. I had the color of the snowflakes be chosen randomly out of the three colors given. I decided to make the show flakes appear under and on the right and left side of the snowman. Here is the final scene that I came up with portrayed at different rotated angles.
The final task was to pick and complete an extension. I chose to make the objects in my scene scalable and moveable. To do this I took the main function that called my entire scene and gave it the parameters x0, y0, z0, scale. I then went through my code and every time I specified a location I added x0, y0, or z0 depending on the direction and multiplied it by scale. By doing this my scene was able to me moved and scaled. When I call my function at the bottom of my code, I am able to add the locations and scale to move and scale my scene. Here are some pictures showing what I accomplished.
In this final project I learned all about the three dimensional turtle. I learned how to pitch, roll, and yaw to manipulate the turtle into drawing the three-dimensional shapes that I wanted. I also applied former knowledge of making a complex shapes with simple objects but instead applied simple three dimensional objects to this thought. Overall I learned an immense amount about computer science this semester and I'm glad that I took the class.