NMM: Week 1 - Bouncing Balls

will langford



Python - Matplotlib

I first wanted to get animation with matplotlib working. This took a bit of debugging but I utlimately got it working by following this tutorial and changing the matplotlib backend (there is a known issue with osx). I'm used to Matlab so it'll get a bit of getting used to but I think I may find matplotlib to be more powerful in the long run. I especially love the ability to export gifs by just using imagemagick as the writer:

anim.save('animation.gif', writer='imagemagick', fps=30)


Canvas - HTML5

I decided to give Canvas a shot next. This was surprisingly simple and satisfying. I didn't make my example very advanced but it seemed intuitive for how I would go about adding layers of complexity. It's interesting to note how performance is definitely dependent on where it is run. It performs very well in my chrome browser, slower in safari, and grinds to a halt on my iPhone.

Your browser does not support the HTML5 canvas tag.



Up until now I'd been computing the physics from scratch. Now I wanted to play with physics engines. Box2dWeb seemed like a nice place to start; it's a javascript version of originally flash based code. It required quite a bit more time investment to get it going and I had a number of failed starts. This was by far the best tutorial I found on the subject (the box2d stuff is way at the bottom). Ultimately I got it working, albeit with a fairly simple example, but it's inspired me to start thinking about physics based design tools that I want to make.

Move the mouse to change gravity

Your browser does not support the HTML 5 Canvas.


Open Dynamics Engine + Python + Pygame

Continuing my exploration of physics engines, I thought I should give Open Dynamics Engine a try. It seems like pretty comprehensive physics engine with python bindings (pyODE). I was surprised by how easy it was to get up and running. I originally had few problems with depencies on my mac but I managed to resolve them (the trick was using macports instead of configuring/installing them myself) and got all of the tutorial examples working right away. I took the double pendulum example and modified it by adding a wall, a floor, and collision detection. Adding the collision detection took some effort but I worked it out (tutorial 3 helped a lot).

A pendulum with a small mass barely nudges the wall...

but one with a big mass...


CBA 2014