Vector/Quaternion classes

I need to do some vector and quaternion processing in a script. I could probably write what I need to do myself (simple component-by-component addition and subtraction), but I’d like to know what you guys use for 2 and 3D vectors and quaternion classes. Is there a pretty standard-use module that most people use?

i ended up writing my own, I guess mainly coz I’m an idiot that likes re-inventing the wheel… but I believe the old mayapy project has some reasonably complete linear algebra modules u can use.

surprisingly I had a hard time finding anything like this already though…

Have a look at euclid http://pyeuclid.googlecode.com/svn/trunk/euclid.py.

It covers vectors and quats plus matrices, rays, some point/line/circle intersection and even some simple geometry primitives. It’s handled most things I’ve thrown at it.

Another possibility is the numpy module. It doesn’t have quats AFIAK, but it’s arrays can used like vectors and support most vector operations (but not dot, strangely).

Thanks Drea,

I ended up creating a Vector4 class from the provided Vector3 class, since their quaternions are too quaternion-ish (I just needed to add, subtract, and normalize them together… would probably be able just modify the quat class instead though).