HW1: 2D Shapes

Due Thursday 12/10 @ 10:30am.

Where & What to Hand In

Note that it's important to always use exactly the specified filename when handing in work for a CS class. (Canvas may automatically append a number to your filename; that's okay.)

Your Tasks

  1. Download the starter code, shapes2d.py. This Python script has a number of TODO comments in it; your task will be to do what they say, one by one, and remove each TODO as you complete it.
  2. Change the body of polylineXAxis() so that it matches the TODO comment. Test this by changing the call to the function in main(), giving it a higher K value.
  3. Further modify the line in main() where you call polylineXAxis() so that the line appears in quadrant 1 of the plane (upper right).
  4. Change the body of polylineVee() so that it matches the TODO comment. Put a call into main() so that a V shape appears in quadrant 2 (upper left).
  5. Change the body of polygonSquare() so that it matches the TODO comment. Put a call into main() so that a square appears in quadrant 3 (lower left).
    • Keep in mind the counterclockwise/right-hand-rule convention for polygons.
    • Note this is a polygon, not a polyline, so make sure you use the right plotting function.
  6. Change the body of polygonCircle() so that it matches the TODO comment. Put a call into main() so that a circle appears in quadrant 4 (lower right).

I will test your functions with many different values of K, including 0. (I won't use negative, fractional, or non-numeric values; don't worry.) Make sure you verify that your functions work correctly in all cases.

In the end, your goal is to produce a figure that looks something like this. Note that I've chosen a different K value for each shape, so that the points are not too crowded but not too sparse. The K values for the line, V, square, and circle, respectively, are 4, 4, 3, and 10.

Rubric

This assignment is worth 15 points.

CriterionPoints
Program runs from command line as python shapes2d.py.1
Displays window and keeps it open.1
Shows line in quadrant 1, with points along the middle.1
Shows V in quadrant 2, with points along the edges.1
Shows square in quadrant 3, with points along the edges.1
Shows circle in quadrant 4, with points along the circumference.1
polylineXAxis() returns correct values for several arguments.2
polylineVee() returns correct values for several arguments.2
polygonSquare() returns correct values for several arguments.2
polygonCircle() returns correct values for several arguments.2
Points in square and circle are arranged in the correct order.1
Total15