Assignment 11 (Philip Prosapio)
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Philip Prosapio
Spring 2010 - CS151

Note- My code for this project is in the pwprosap account on the academic server.

Summary

For this lab we were taught how to use the 3D turtle and were then asked to create multiple simple 3D objects for the first task, like a cube or pyramid, etc. Then we had to put these shapes together to create a simple 3D scene. The final task asked us to take a extension and complete it but then give a detailed description of how we completed it in this write-up.

Solution to Tasks

1) For the first task I created five different simple shapes. A cube, pyramid with a square base and a pyramid with a triangular base, a prism and a rectangular box. To help us make sure that these objects were created correctly and that they were oriented right we were able to use some code to create a coordinate axis to help us is the creation process. Here is the code for the axis:

def drawAxes():

  1. Draw the axes (y in blue, x is green, z is red)
  2. y-axis
    ln = Line(distance=300, color=(0,0,1) )
    ln.setWidth(5)
    ln.draw( 0,0,zpos=0, roll=0, pitch=0, orientation=90 )
  3. x-axis
    ln.setColor( (0,1,0) )
    ln.draw( 0,0,zpos=0, roll=0, pitch=0, orientation=0)
    #z-axis
    ln.setColor( (1,0,0) )
    ln.draw( 0,0,zpos=0, roll=0, pitch=90, orientation=0)

The picture of all of my shapes, but not the axis, is attached and labelled picture1lab11.png .

2) For the this task I created a city street with two rows of houses on opposite sides of a street with a sun in the sky. For this task I had to make sure all of my objects had the correct dimensions so that they would fit together, an example is that I had to make sure my cube face was the same size as the bottom face of the square pyramid. I also decided to make a sun out of my pyramid shape. I used the for loop below to rotate the pyramid around an axis to make a sun like object.

for i in range(360):
p = Pyramid(1, 'yellow')
p.setStyle('jitter')
p.setWidth(1)
p.draw(-100, 250, zpos=100, roll=-90, pitch=01.0*i, orientation=0, scale = 0.5)

I took two pictures of this scene from two different angles and perspectives. They are attached and named picture2lab11.png and picture3lab11.png .

3) For the task of taking an extension and completing it I chose the extension that had me create a drawing style that I had not created yet and make it. I chose to make a drawing style that was was slightly based off of the dash style but just more advanced. I called it my 'crosshatch' style, in which instead of having individual dashes in the place of a line, I made it so each line was made up of perpendicular slashes that form X's. My approach was to keep the same code from the dash style to determine number of dashes but then I needed to make the code that would change the orientation and draw the two perpendicular slashes.

for i in range (numdash):
ori = turtle.heading()
pos = turtle.position()
turtle.setheading(60)
turtle.forward(self.dashLength)
turtle.left(180)
turtle.forward(2*self.dashLength)
turtle.setheading(ori)
turtle.goto(pos)
turtle.setheading(-60)
turtle.forward(self.dashLength)
turtle.left(180)
turtle.forward(2*self.dashLength)
turtle.setheading(ori)
turtle.goto(pos)
turtle.up()
turtle.forward(10)
turtle.down()

The key parts of this code that made the crosshatch style work were the two variables ori and pos. These two variables saved the position and orientation of the turtle each time

Extensions

Extension 1 - For my first extension, I fulfilled the extension that required me to make a new draw string type. For my new draw style I decided to make a stye that reminded me of sketching. This code makes it so it looks like each object has had each of its lines sketched multiple times lightly. I just used a 'for' loop on my broken line code and changed a few other things to make my shapes looked like they had been lightly sketched. The picture of my new draw style is attached and named picture5lab10.png .

Extension 2 - The second extension that I did completes the extension that asked me to make another Lsystem. I spent some time fiddling around with different bases and rules, not really using any specific starting point. I created the new Lsystem, sysproj102 and here is what it looks like:

base (50)F+(50)F-(50)F(135)(141.4)F(135)(50)F
rule F F+F-

The picture of the Lsystem that I created for this extension is attached and labelled picture6lab10.png .

What I learned

For this lab I came to understand more about how to call different types of functions, like the the difference between calling shape classes and Lsystems. Before this lab I was pretty hazy on exactly what I had to do for the different types.

Attached Pictures

Labels
  • No labels