Assignment 2: Trees and DXF Files

Watch this brief clip of Dan Garcia graphically demonstrating recursion in BYOB (Build Your Own Blocks), a variant of Scratch:

Instructions

  1. Here is Python code inspired by Dan's "vee" program. Try running it. If you need to install Python first, see the Software Setup page for instructions.

  2. Here is Python code that generates the outline of a tree that can be laser cut. It also generates a DXF file. But it uses only one terminal shape: a square. Note: this code requires the dxfwrite package. If you need to install dxfwrite on your computer, see the Software Setup page for instructions.

  3. View your generated DXF file in DraftSight to check it for correctness. You may need to do View -> Zoom -> Fit in order to center the figure in the DraftSight graphics window.

  4. Modify the treegen code by adding three new terminal shapes. One of these must be a ring (donut). Note: the inner ring of the donut must be a different color so that it can be cut before the tree outline. Note: you must use an arc primitive to draw your arc; do not try to approximate it with a polygon. The other terminal shapes can be a five-pointed star, a hexagon, an arrowhead, or whatever you like.

  5. Note: the "turtle", Tkinter, and the DXF file all use different coordinate systems. For example, for the turtle a heading of 90 degrees means "up", whereas in Tkinter a theta value of 90 degrees means "to the right". You will have to deal with this when coding your new terminal shapes.

  6. Now engage your creativity: you can change the size or number or angles of the branches, set minimum and maximum depth values for the tree, have branch thickness vary with depth, or do whatever else you like to make this project your own. But you cannot use this freedom to "dumb down" the assignment; you still must have at least four different terminal shapes, at least one of them must involve an arc, and at least one must involve a hollow shape. (The donut satisfies both criteria.)

  7. Make two trees on the laser cutter, one with stand type A and one with stand type B. Each tree must have at least 5 terminal nodes. Share plastic with your classmates so that the trees can be of different colors.
Here is an example of a tree structure a student created in a previous course, using an older style of stand:

Click for larger version.

What to Hand In

  • Hand in your Python code and your two DXF files via AutoLab.
  • Post a picture of your assembled two-component tree to Piazza in the thread provided for that purpose.
  • Also bring your assembled tree to class on Wednesday to show off.
  • Everything is due by Wednesday, April 1.

Grading

  • 7 points for correct Python code
  • 2 points for generating trees with at least 5 terminal nodes and complementary slots
  • 1 point for cutting the plastic and posting a picture of the assembled tree to Piazza

Back to 15-294 course home page

Last modified: Sun Mar 29 13:30:51 EDT 2015