## Monday, February 4, 2013

### Spirograph 2 - GeoGebra Animation

Okay, I've played with cycloids before. But when Guillermo recently updated his hypocycloid tutorial, it gave me the push to play again, since I'm always trying to get better at the GGB. Making it helped me understand GeoGebra animation a bit better, so I thought I'd share. I also think the resulting sketch could be the basis of a pretty nice open ended activity. Obviously, having too much fun.

As good as Guillermo's instructions are, I'm the student who wants to figure it out for himself. One of my easiest teaching mistakes is to assume that my students are like me, and to provide too little support. Although I can overcompensate and then dictate too much, too. To provide student choice is the ticket.

So I started with the circle. I debated about making the controls be the radii for the boundary circle and the rolling circle, but finally decided to make it the boundary radius and a fraction of that for the rolling circle. Originally just a decimal, 0 to 1 incrementing by .05, but eventually I decided to make it a proper fraction, and on the slider control made the increment 1/60. It will show as a decimal approximation, but GGB stores it as the fraction for all practical purposes.

Then the rolling. The usual thing to do animation is to make a slider for time. My first take was to have the slider just go from 0 to 2$$\pi$$. (Or 0 to 360 degrees, but I didn't want the units hassle.) Then I increased it to 10$$\pi$$, but finally decided that it's neat to choose the number of rotations, so I made a 'circuits' slider for how many revolutions and defined the time slider to go to circuits*2$$\pi$$. I use sliders instead of input boxes when possible because the input boxes don't work in HTML5/mobile devices yet.

Now the geometry. Really the rolling circle slides around the boundary at a contact point, rotated by the time slider away from some arbitrary starting point. The rolling you simulate by rotating the sliding contact point around the small circle. But how far does it rotate? My naive first take was that it should be as far as you've slid around the larger circle, thinking about it as a distance, like a string wrapping around. When you've gone angle $$\alpha$$ around, you've gone distance $$\alpha$$*radius. Putting that in...
... pretty! But not a trochoid. It took me a few minutes to realize that I wanted the angle to rotate, not the distance. So if the circumference you've traveled is $$\alpha$$*big radius, then that's
$$\frac{\alpha * \text{big radius}}{ \text{small circumference} } = \frac{\alpha *a}{2\pi*\text {small radius}} = \frac{\alpha *a}{2\pi*b*a}= \frac{\alpha}{2\pi*b}$$
So the angle is $$\frac{\alpha}{2\pi*b}*2\pi$$ or just my time&angle variable divided by my radius ratio, t/b. I still have to think about what happened with the first try - obviously there's something mathy there.

It didn't look a lot like it was rolling, so I added the spokes to the small wheel by rotating a segment from the center to the rolling point around the small circle center.

Since I added the number of circuits as a variable, it made the speed of the sketch animation change and I couldn't find a value that was good for any number of circuits. But when I added a slider for the speed of the animation, I lost the play/pause button for the time. You can still control it with a right-click context menu, but that's not very user friendly.

So I started digging around the GeoGebra manual for animation controls, and finally found StartAnimation.  In particular, the boolean version,
StartAnimation[ point, slider, ... , boolean]
animates whatever is listed if the boolean is true, and stops it if false. Now I could make a boolean variable for animation (called 'animated' here), and control it with a button.

I'm using SetValue more than variable assignment lately because it avoids some weird issues that come from fixing a variable. ("!" is the text version of $$\not$$ ) This also allows me to make the animation of t just a once through instead of repeating, which makes choosing the number of circuits more relevant. Here's the final version of the time slider:

To make the sketch more Spirography, I  took out some of the erasing and timer resetting from the scripts for sliders and buttons, and added in the color controls for the pen. The color values in GeoGebra are between 0 and 1, as opposed to 0 to 255 in some programming.

Activities/Problem ideas:
• Given a ratio, how many circuits to completely draw the hypotrochoid? How many vertices will it have?
• How are the hypotrochoids for ratios with common denominators similar and different? Why does that happen?
• Make an image that is aesthetically appealing to you. Document your process. What did you have to figure out to make it? What math can you see in the final image?
• What kind of mathematical curve is one side of a hypotrochoid? How do you know? Can you prove it? Why would it be that way?
• Give students a challenge image, and ask them to duplicate it or investigate the mathematical properties. Or ask them to make a challenge image for another group then swap.
How else might you use a sketch like this?

Here's the sketch at GeoGebraTube or as an applet (works on mobiles).  Hope you have at least 11/60 as much fun as I did with this.

Post Script:
With that work done, it's been easy to add features. I added a mirror point on an outside circle so that the sketch could do epicycloids. Then I dilated the pen points from the center of the rolling circles to get full on trochoid glory. Here's the final sketch on GGBT and mobile app.

Have fun! Send me a cool image!

1. 2. 