CPSC 120: Lab Assignment 5

Due at 11:59 pm on Friday, 03/31/2017

Home | Calendar | Announcements | Assignments | Example Code | Notes

Reading

Problems

Problem #1

Write a sketch that plots 32 evenly-spaced dots around a circle. This is very similar to what we did in class, with one important exception: the first dot should lie on a line between the current mouse location and the center of the circle, and this should change with the mouse movement. All of the remaining 31 dots should be spaced around the circle relative to this first one.

There is also a coloring expectation: the first dot should be a very bright or very dark color. Each one after that should be progressively darker or lighter (depending on which direction you choose).

Problem #2

Write a sketch, connect, the form of which is determined by two variables: an integer, n and a floating point value, p. The method should plot n points, evenly spaced around a circle. Then, for each pair of points, it should draw a gray line between them with probability p

connect 16 points, with probability for each line of 0.05 (5%)
connect 16 points, with probability 0.125
connect 16 points, with probability 0.45
connect 16 points, with probability 1.0

Tip #1: This problem involves the drawing of n evenly-spaced points around a circle as a subproblem.

Tip #2: The key insight for the line drawing is to observe that from each point, we're going to consider every other point (what kind of control structure does this kind of nested iteration?). Then we *might* draw a line to it (with probability p). As a first attempt, try just drawing the lines. Then go back and study the discussion we had in class on probability techniques. In particular, the bubbles.pde sketch from the Example Code section of our class website illustrates the necessary techniques.

Problem #3

This problem builds on the previous two. In particular, your sketch here should have a number of points that begin on a line between the mouse pointer location and the center of the circle, with the others evenly spaced relative to this. You'll also draw lines from each point to every other point, with some probability p.

The twist is that, as you move further from the first dot (the one that lies between the mouse and the circle's center), the probability of a line drawing will decrease. It will be at its highest probability value at the first dot and its lowest value at the point halfway around the circle. As you keep drawing past this halfway point, the probability of a line being drawn will increase again, back to its full value at the first point.



Standards

Turn in

As with all assignments for this course, submit the folder containing your Processing sketches. This should be a single folder named "hw5", which will contain your two sketches. You do not need to submit a paper printout of anything. Again, the turnin directory is

~lasseter/classes/cpsc120/<your last name>


John H. E. Lasseter