Thu, 20 Nov 2008
Spherical Physics and Rewrite of Fabric class
« Forking and a pinch of Intelligent Design | Main | Marshalling & Persistence » Posted by at 10:01 AM in Code
In this podcast episode I describe two of the improvements that I have been able to make in the past couple of months during evenings and weekends. Time has been tight lately since I've been working intensely on my contract with the team at the European Library to finalize the site which is finally going live right now. The project is called Europeana and it functions as a search engine for a mountain of metadata about european cultural heritage collections from all over the continent.
There are now two different variations on the Physics class (two subclasses) which are identical except for the way they treat gravity and the walking surface. The original one, VerticalPhysics, has gravity pulling in the -z direction and the floor is the plane where z=0. The new physics has gravity pulling "inwards" and the floor is actually the surface of a spherical planet. The critters can now exist and move around on the sphere surface, and therefore they will tend to encounter each other for the first time.Also, I've managed to implement a really nice simplification of how the Fabric class works. Fabrics used to be just joints and intervals with these two things mutually pointing at each other, so it was possible to ask a joint for the intervals that meet there. This involved a lot of bookkeeping when the fabric was being edited, and things started getting complicated when I introduced "faces" (trianglular), "tetras" (four joints), and even "vertebra" (those tensegrity modules). Should a joint also be aware of the faces, tetras, and vertebrae to which it belongs? Too much work.
The way the Fabric class works now is that it's centered around the joints, and they hold no references to any other entities. Instead collections of faces, tetras, and vertebrae can be extracted from a fabric using what looks a bit like an SQL query. Give me the tetras connected to joint X. Since it's all in memory these queries are lightning fast, and it makes the code quite a bit simpler.
I've built quite a bit of other stuff already too, but I'll talk about those things in subsequent podcasts soon, now that I have a bit more time available. Stay tuned!
Technorati Tags: evolution darwin geometry physics