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. This garcia.py file 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. This treegen.py file 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.

  3. The treegen program requires the dxfwrite package. Just unzip it into the directory containing your own code.

  4. View your generated DXF file in Inkscape to check it for correctness.

  5. 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. You must use an arc primitive to draw your arc; do not try to approximate it with a polygon. And you must correctly calculate the endpoints of the arc to exactly meet the branch endpoints; you are not allowed to fudge it by hand-tuning a constant. You will have to solve the arc drawing problem twice: once for Tkinter and once for the DXF file. This diagram should help:


    Why the donut? This course is about more than just how to use SolidWorks. It's intended to give you some insight into how the technology works. SolidWorks performs complex geometry calculations to enforce relations, apply constraints, and render the results. Making a mathematically correct donut shape gives you a taste of the kind of mathematical reasoning behind these algorithms.

  6. The other two terminal shapes can be a five-pointed star, a hexagon, an arrowhead, or whatever you like.

  7. Note: the Tkinter canvas and the DXF canvas use different coordinate systems. Both the scaling and the positive angle direction are different. To help you convert between the separate coordinate systems, we've created a helper function named 'dxf_angle' that accepts as input the angle you would have used to draw in Tkinter and returns the angle you should use to draw in DXF.

  8. 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.)

  9. 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, and all four shapes must appear somewhere; it doesn't matter which shapes appear on which tree. 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 an earlier instance of this course:

Click for larger version.

What to Hand In

  • Name your DXF files based on the color of acrylic you want to use, e.g., "green.dxf" and "blue.dxf" if you want one part cut from green acrylic and the other one from blue. If you want both to be the same color then name them "green1.dxf" and "green2.dxf".

    Color choices are: red, green, blue, yellow, white, black, and clear.

  • Put your Python code and your two DXF files in a zip file and hand it in via AutoLab.
  • Post a picture of your assembled two-component tree to Piazza in the thread provided for that purpose.

Grading

  • 14 points for correct Python code
  • 4 points for generating trees with at least 5 terminal nodes and complementary slots, correctly colored
  • 2 points for cutting the plastic and posting a picture of the assembled tree to Piazza

Back to 15-294 course home page

Last modified: Mon Nov 7 21:28:33 EST 2016