Polar Coordinates, Sine, Cosine…
Monday, October 13th, 2008One of my many favorite equations is the conversion from polar coordinates to cartesian... in actionscript it looks like this:
-
x = radius * Math.cos(theta);
-
y = radius * Math.sin(theta);
I was teaching the ins and outs of polar coordinates to my students yesterday and thought of a good assignment for them... "Use Graphics or BitmapData to create an interactive sketch involving the polar to cartesian conversion." Now, when I first encounted this equation, I didn't really know what it was or why it worked... I used it for circular motion in Director... I also tried randomly tweaking it to see what kind of results I could get.... things like this:
-
// sort of like a figure 8
-
x = radius * Math.cos(theta);
-
y = radius * Math.sin(theta/2);
-
-
// an oval
-
x = radius/2 * Math.cos(theta);
-
y = radius * Math.sin(theta);
-
-
// etc...
-
x = radius * Math.cos(theta);
-
y = radius * Math.sin(theta) + radius * Math.cos(theta * 2);
I advocate this kind of random experimentation when I teach game design or talk to students interested in generative visuals. Playing with the numbers just improves understanding... even if you don't know what your playing with at first...
When I got home yesterday I created this small sketch:
To see the flash version continue reading this post....