Originally published on: Sun, 14 Mar 2010 17:11:27 +0000
Today is March 14th. It's Albert Einstein's birthday. Does anyone else find it interesting that many of us in the U.S. accelerated time by one hour on his birthday?
It's also Pi Day ... 3.14.
I usually try to do something nerdy on Pi Day. Last year, I wrote a quine. I'm getting tired of quines, so I decided to do something that actually involved the use of Pi.
Back in the 80's, my brother showed me a technique that could be used to plot points on a circle. The sine and cosine functions available on his microcomputer accepted arguments in radians. To convert degrees to radians, one had to multiply the argument by Pi and then divide by 180.
The formulae for determining a point on a Cartesian plane goes something like:
x=cos( degrees * Pi / 180 ) * radius y=sin( degrees * Pi / 180 ) * radius
In order to adjust the point-plotting for a computer screen ( which did not understand negative coordinates on the x and y axes ) one needed to add the radius again:
x=cos( degrees * Pi / 180 ) * radius + radius y=sin( degrees * Pi / 180 ) * radius + radius
I have altered this formulae for use in JavaScript:
I threw together a little HTML5 document that draws a circle on a canvas element using these formulae. It slowly draws a circle from by drawing a line from the center to the desired point. The final output looks like this very small thumbnail picture.

You can watch the graphic render in a much larger area by clicking here while using an HTML5 compliant browser ( such as Firefox ):
http://www.mailsend-online.com/wp/piday.htm
Unless otherwise noted, all code and text entries are Copyright ©2010 by James K. Lawless
Views expressed in this blog are those of the author and do not necessary reflect those of the author's employer. Views expressed in the comments are those of the responding individual.

Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Click **here**
A JavaScript REPL for Android Devices
A Review of Kevin Mitnick's Book Ghost in the Wires
Play MP3 Files with Python on Windows
Checking Shift States with DEBUG
COM Scripting in C by way of JavaScript
Thwarting HTTP Referer Trackbacks
Why Some Web Sites will go Dark on Jan 18th
Book Review : Paull Allen - Idea Man
A 90's Experiment in Online Systems - The U.S. West CommunityLink Service