Fun with rectangles – learning the rotate() method

While a lot of the kids these days prefer the graphical interface of Scratch, there have been sightings of javascript wizardry. We use Khan Academy, which provides a limited set of js methods and functions, and some nice features like automatically rendering whatever we put in the draw() function.

But until recently, it was painful to draw any shapes that were not perpendicular to the cartesian axes. The only way I could do it in my spaceman game was to introduce a variable called angle and then apply sine and cosine to figure out the coordinates of the rotated shape. This worked ok, but 5th graders haven’t learned trigonometry yet! (Aside: I have *caught* a few of the coders watching Khan Academy math videos, so apparently there is a link between programming and math.)

Fortunately, the Khan Academy team added a method called rotate(), and Carter learned the power of libraries. Take a look at this graphic he made by drawing a bunch of identical rectangles, but with each one rotated and scaled differently.

Easier than learning trig, and a nice looking picture. Way to go Carter!

Leave a Reply

Your email address will not be published. Required fields are marked *