Nov 14 2007
Pyglet Great, Math Hard
I’ve blogged about my random obsession with bees in the past. The release of Pyglet encouraged me to pick it up again and try to make a bee-system associated with coordinates rather than with abstract “locations.”
Over the weekend, I started to write a trig library that could compute angles and distances, so I could move my bees around a grid. It turns out, I’m pretty bad at math. Brant Harris sat down and explained Vectors to me in about 15 minutes. I immediately ditched my trig library, and built a basic Vector bee demo in a half hour or so last night. The code for it is in my expansive public-works repository. In that same module is trig.py, which is the start of the trig library I ended up ditching. The Vector work was already written in PyEuclid, the very excellent Euclidian Geometry library written especially for Pygame development.
The code, suitable for cutting and pasting, is as follows:




So, of course the first question that pops into *my* head when I hear about this PyEuclid, is, “does the existence of a python euclidean geometry module suggest the existence of a python non-euclidean geometry module?” The answer, I am happy to report, appears to be yes, at least one: http://pygeo.sourceforge.net/
Awesome!
The title is misleading, i had the impression before reading the post that Pyglet was bad at handling ‘math’ where as it’s you that sucks at math (which i do too!).