tartley at tartley.com
Mon Apr 25 06:49:34 EDT 2011
On Apr 20, 2:43 pm, Andreas Tawn <andreas.t... at ubisoft.com> wrote:
> > Algis Kabaila <akaba... at pcug.org.au> writes:
> > > Are there any modules for vector algebra (three dimensional
> > > vectors, vector addition, subtraction, multiplication [scalar
> > > and vector]. Could you give me a reference to such module?
> > NumPy has array (and matrix) types with support for these basic
> > operations you mention. See the tutorial athttp://numpy.scipy.org/
> You might also want to considerhttp://code.google.com/p/pyeuclid/
Stealing this from Casey Duncan's recent post to the Grease users
- (ab)use complex numbers for 2D vectors (only). Very fast arithmetic
and built-in to Python. Downside is lack of abstraction.
- Use pyeuclid (pure python) if ultimate speed isn't an issue, or if
compiled extensions are. It supports 3D and has a nice api
- vectypes is a more recent project from the same author as pyeuclid.
It offers a more consistent 'GLSL' like interface, including
swizzling, and internally seems to have more maintainable code because
it generates various sizes of vector and matrix from a single
template. This is done without performance penalty because the
generation is done at design time, not runtime.
- Use pyeigen if you want fast vectors, and don't mind compiling some
C/C++. I don't know how the Python api looks though
- Use numpy if you want fast batch operations
More information about the Python-list