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
Save to del.icio.us
Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Subscribe!
Auto Save Clipboard Images Redux
Extending SpiderMonkey JavaScript on Windows
Rhino JavaScript to EXE with launch4j
Compiling Rhino JavaScript to Java
Directory Traversal in Rhino JavaScript
A Command-Line MP3 Player for Windows
Auto Save Images from the Clipboard
Java in a Windows EXE with launch4j
An Interview with Tom Zimmer: Forth System Developer
Setting Windows Console Text Colors in C
Learning Z-80 Assembly Language on the TRS-80
A Simple Media Control Interface Script Processor
A Simple Parser for a Small Command Line Interface
COM Scripting in C by way of JavaScript
Twimmando: A Command-line Twitter Client
Command-Line Image Format Conversion
MicroISV on a Shoestring
DadHacker
The Bottom Feeder
Writin' That Code!
The Recursive ISV
The Thomsen Blog
Prototypically Speaking
The Reinvigorated Programmer