Comp 150-001, MWF 12:35, Crown 105

Week 9

### Homework 7: Illusions

Implement an optical illusion. One of the following is recommended:

• Stepping Feet: This is probably the easiest. Do the stripes with rectangles.
• Stroboscopic Alternative Motion: The flipping circles are relatively easy; the harder part is to create a control. The simplest control, for speed, is to create a long vertical rectangle, say at the right. When clicked in, the control value is adjusted according to the y-coordinate of the click position. Maybe the most important control value is the aspect ratio, which should vary from around .5 to 2.0. For a fixed diagonal distance d, and aspect ratio ar = height/width, width = d/(1+ar**2)**0.5 and height = d*ar/(1+ar**2)**0.5.
• Pigeon Neck: Like Stepping Feet, it is relatively straightforward to draw the vertical bars. The harder part is to draw the pigeon figure. I suggest you make a polygon shape, and stick with that. I propose the following fifteen points to outline the pigeon (about 110 pixels tall). The origin here is at the back of the pigeon's head:
(0,0), (30,0), (30,20), (40,20), (40,30), (24,30), (24,80), (5,80), (5,104), (15,104), (15,110), (-5,110), (-5,80), (-50,80), (0,30)
I suspect that the forehead must be aligned a little forward of the front of the body, here 6 pixels. Does it matter if the width of the rectangles is, say, 12 pixels? Try to move the pigeon 1 pixel (1 unit of x) at a time, with a suitable delay. According the the website, "[the pigeons'] heads are one stripe ahead of the body, thus the nicking motion ensues."
• Stereokinetic Effect: Ultimately made of circles that are moving. Moving a circle around a circle is the same as moving its center. This is done for one circle with the orbit code below. Note that all the circles (except the outermost blue one) are orbiting the center of the main circle here. Using the notation of orbit.py, the circles will all have the same t, but with different circle radius and different R (the orbit radius). If you draw the circles alternating blue and yellow, they should stay in that stacking order indefinitely. To move all the circles, make a list of them, each with their orbit radius R, and update them each in turn.
• Munker Illusion: Not animated, but an option anyway.
• Rotating Snakes: Another non-animated illusion, but definitely taking some effort to set up.

These and other illusions can be found at michaelbach.de/ot.

After you make your illusion, experiment with it. Does the stripe width matter for Stepping Feet and Pigeon Neck? If you see the circles in SAM flipping vertically, do they stay that way as you move the aspect ratio towards 1.0? Can you think of other experiments?

illusion1.py

drawing the pigeon.
Let coordlist be the list of the above coordinates, as tuples in Python. (You can just paste it in to Idle.)

pointlist = []
for (x,y) in coordlist:
pointlist.append(Point(x,y))
pigeon = Polygon(pointlist)
pigeon.move(200, 100)
pigeon.draw(win)

The forehead of the pigeon has x=30. The front of the body of the pigeon has x=24. You can play with these (probably by slightly reducing the latter) to make the pigeon fit with your vertical stripes.

Orbit: Here is the main method from orbit.py:

global WIN
center = Point(WINX/2,WINY/2)
sun = makeDisk(center, 15, WIN, "yellow")
t = 1
#delay = 0.01
oldx = R*math.sin(t)
oldy = R*math.cos(t)
planet=makeDisk(Point(WINX/2+oldx, WINY/2+oldy), 8, WIN, "blue")
while not WIN.checkMouse():