If you found this blog entry, then you probably found it through my MIX 2010 10k Challenge entry. The link to my application in case you are actually reading my blog should be here soon is here.
In grade school, I got to go on several field trips to the Oregon Museum of Science and Industry (OMSI - www.omsi.edu) . OMSI used to be located up by the Portland Zoo in those days. The exhibits were a bit different too. But I recall going there and seeing the pendulum drawing table. It was this pen suspended from a pendulum and there was a drawing surface also in motion. You could push it around and watch different interesting shapes appear from the motion of the pendulums. This immediately came to mind when I decided to write something for the 10k challenge.
The name for this device is the harmonograph. The short definition is that it is a device for creating geometric images using pendulums. A pendulum is any kind of weight suspended by something like string so that it can swing freely. Pendulums are thousands of years old and used throughout history. Harmonographs were invented and gained popularity in about 1890.
There is a Silverlight article about animation techniques that uses a pendulum (www.silverlightshow.net/items/Custom-Animations-in-Silverlight.aspx). I went to that example first. The formula for that pendulum required solving a differential equation. So, while the article is great for illustrating how to simulate a basic lateral pendulum in Silverlight, it still wasn’t quite enough about how to build a better harmonograph.
What I really wanted to do was break away from the profile view of a 2D pendulum and show animations for the paper and the pen. The obvious physics engine for Silverlight is the Farseer Physics engine (www.codeplex.com/FarseerPhysics). However, the source code for this project had to be limited to 10k. Adding the assemblies for Farseer makes the whole project go way over 10k. So, before trying it, that was also out the window.
My research led to a very simple mathematical solution. Based on more internet research, I found a great little book, “Harmonograph: A Visual Guide to the Mathematics of Music” by Anthony Ashton (www.woodenbooks.com/browse/index.php). Wikipedia also had the basic formulae and explanations I needed (en.wikipedia.org/wiki/Harmonograph). The basic formula for a lateral pendulum with the assumption that air or other forces in addition to gravity will slow down the motion over time is:
xt= Atsin(f*t + p)*Exp(-d*t), where t=time, A=amplitude, f=frequency, p=phase, and d=damping factor.
It looks daunting but in practice, it’s pretty basic. For each point in time, 0 to 100 for example, calculate the X point of the lateral pendulum based on the A, f, d, and p of the pendulum. This is for a single pendulum. To get an x,y position for a two pendulum system, you apply the same formula and solve for the Y point. There are two pendulums for the pen and two for the paper. So, there are four calculations for each value of time.
One of the things I found in my research was a frequency given but not a length. If I had more than a 10k limit you would see form fields to enter the length instead of the frequency. Amplitude is simply the angle from the resting position of the pendulum. Frequency is a measure of the time it takes the pendulum to swing once and is estimated using the formula: 2pi*Sqrt(Length/Gravity). This is the simpler version of the formula because larger Amplitudes affect the frequency over time (hence the more accurate differential equation). Gravity is assumed to be 9.807 m/s2. The simplest way to understand frequency is that it is the cycles per second the pendulums travels (1Hz = 1 cycle per second). Damping is the affect of friction on the pendulum by air. The larger the damping factor, the sooner the pendulum swings will slow down.
The Silverlight simulation I wrote for the MIX 2010 10k challenge is the first I’ve seen of a harmonograph. Most of them found on the internet are written in JavaScript. Another simulator out there worth mention is from Michael Croucher. He wrote a simulator using the Wolfram Demonstrations Project (demonstrations.wolfram.com/SimulatingHarmonographs/).
The big differentiator with this Silverlight version is that you have to wait for the drawing to finish and you can enjoy watching it reveal the final shape.
Here is the full version of this application with the setting editors and isolated pendulum displays.
This is what the 10k application looks like.
