Wednesday, May 16, 2012

Toilet Paper Problem

What would it look like if you marked each perforation on a roll of toilet paper and rolled it all back up?  A striped pattern?  A spiral pattern?  I wondered about that in college, and wrote a program to answer the question - here's it's latest incarnation:
(The link above goes to a Processing app requiring Java - if it doesn't work, try this Flash version).

Of course, the pattern depends on the sheet thickness and the sheet length.  Try clicking different places on the screen - the farther your mouse is to the right, the thicker the sheet, the farther down, the longer the sheet.  I was surprised at what a difference small changes in these values had on the overall pattern.  My fractal sense is tingling - is yours?

At one point I found an article about this type of pattern (an Archimedean spiral marked at fixed intervals), but have since lost track of it - can you help me out? 

Monday, May 7, 2012

Four ways to start a high school programming course

When I graduated high school in the late nineties, I figured my school was behind the times because it didn’t offer a programming course.  I later found that programming in high school was, and unfortunately still is, somewhat of a rarity. 

After the AP test, I led my calculus classes through some programming concepts using their graphing calculators.  The unit was well-received, and culminated with some reasonable programs. 

But you don’t need calculus to learn to program.  In fact, programming may be the right context to teach math concepts to students in elementary and middle school. 

The relevance goes without saying.

But how to get started?  Here area  few options that come to mind:

  • Alice.  A free development environment for 2D and 3D animations.  Designed as a teaching tool, Alice has a drag-and-drop interface and is many a college student’s first experience with object oriented programming.
  • Processing.  Created as a tool to teach programming in a visual context, Processing allows users to quickly (i.e. simply) create graphics and animations.  Your curriculum is practically ready-to-go – click “learning”.  Did I mention it’s all free?
  • Lego Mindstorms.  Nice drag-and-drop software makes robotics programming a visual experience, and of course commanding a robot to do your bidding is always rewarding.  It’s pretty expensive though, at $280 per kit. 
  • Graphing calculators.  If your classroom has 30 of them, you’re in luck.  Otherwise, this might not work out.  The handheld aspect is convenient, and you won’t have kids checking Facebook on them.  Not object oriented, but hey, this is an introduction.

Thursday, May 3, 2012


I finally got around to trying out Processing a couple of days ago, a programming language for making… well, art.  It’s like a super-simplified Java geared toward graphics and animation.  Needless to say, I became an instant fan. 

Here’s my first program - a Pickover attractor.

1-Fullscreen capture 522012 93119 PM
//xn+1 = sin(a yn) + c cos(a xn)
//yn+1 = sin(b xn) + d cos(b yn)
//where a, b, c, d are variabies that 
//define each attractor. 

void setup(){
float x = 0; 
float y = 0;
float a = -1.4;
float b = 1.6;
float c = 1.0;
float d = 0.7;
float newx = 0;
float newy = 0;

void draw(){

  for(float z = 1; z < 100; z++){
    ellipse(170*x+width/2-40,170*y+height/2-20,3 ,3);
    newx = sin(a*y) + c*cos(a*x);
    newy = sin(b*x) + d*cos(b*y);

    x = newx;
    y = newy;