Vectors, matrices and other euclidian fun

It occurs to me that there's probably still people who aren't aware of the very cool, quite extensive library of euclidian fun called euclid written by Alex Holkner (of pyglet fame). It's been around forever and implements vectors and matrices (with various standard transforms) in 2D and 3D. It also implements a bunch of geometry (points, line segments, circles, ...) and has intersection tests for all of them.

Don't write your own vector class! Use euclid! :)

Maybe one day I'll write a full cython translation of the whole module... but for most uses it's plenty fast enough as plain Python.

(log in to comment)

Comments

Is it still in development? We used it for Flight, and I had a few feature requests, like being able to take the minor of a matrix.
As far as I know Alex is not working on it. It's a simple enough project that could be opened up though...
Getting an efficient vector class can improve action-heavy vector-based games. Euclid is a little behind in that regard. From my tests, having a vector class subclass tuple is the best way to go, it avoids the expensive __init__ call every time a vector is created. A custom vector class for your purposes is almost certainly better than any standard module though, and they aren't that complex to write as is evidenced by the fact that quite a few of them exist.
To tell the truth I just have self.x and self.y. I have a bunch of similar lines for operations on X and Y and where I'm doing more serious vector math it's a bit harder to follow. But at least I neither had to write or learn to use a complicated vector library :). Also there is no instantiation, not even of tuples.