In this podcast i get a start on the Physics class which will be responsible for acting on a tensegrity to make it move and jiggle in a realistic way. This is where tensegrity gives me a wakeup call because i discover that there were some things wrong with the very first steps i took in the previous episode.

The key is that in previous projects i've always created intervals and joints because all intervals were springy, but now with tensegrity i'm making the bold assumption that there are bars and cables, and that the bars are completely rigid. Also bars never connect to each other so a bar can be the full owner of the two joints at its ends.

While writing the Physics class i found myself looping twice through the intervals, first touching the ones that were cables (bar==false) and then touching the ones that were bars (bar==true). That smelled funny. Meanwhile, however, writing the Physics class has required that i start giving Arrow some of its needed functions.

I ended up splitting the Interval class up by making it abstract and creating two concrete subclasses called Bar and Cable, each with its own personality. Bars, for example, create their two joints when they are created, and the joints are dedicated to their bar. Cables connect existing joints (which are bar-ends). Now the smell is gone because a tensegrity contains bars and cables, exactly as it should be, and the Physics class can just walk through the cables, and then through the bars, doing it's work.

The difficult part of this is the explanation of how the physics of bars is programmed, but this is a very important hurdle to jump before we really get going. You'll have to listen to the podcast for the full story.

Technorati Tags: