Double Vortex

My friend Andrew Robbins recently showed me a Physics Girl video on youtube. I thought that was a really awesome phenomenon! So as a collaborative coding challenge, we decided to create a simulation of the vortex. (If it doesn’t appear for you, it means that your browser does not yet support JavaScript 6 Harmony)

We recently discovered koding.com, which is an online coding text-editor and terminal that controls an Amazon Web Server that is provided free of charge, no setup needed. Pretty cool, right?!

But most importantly, multiple people can edit the same document at the same time! (EDIT: koding.com now requires you to set up a team in order to do this)

I created equations to represent the semicircle in polar coordinates, and then to create a “tube” around the semicircle. I decided that we would have particles spinning around the “tube” and the semicircle simultaneously, at random speeds. Andrew created his own vector system that enabled a “camera” to view the 3D points from any viewpoint looking in any direction. You may notice that the semicircle looks more like a horseshoe shape in the simulation. It is not a horseshoe shape. The camera happens to be located near the bottom of the semicircle, which causes this effect.

We use plain old DOM elements for the particles, and CSS to make them appear as circles. We calculated what size they should appear as based on their distance from the camera. And 3 hours later, after grappling with some glitches, we finally had our simulation!

The code is provided below. Keep in mind that this was a timed challenge.

Leave a Reply