Vectors

Algis Kabaila akabaila at pcug.org.au
Tue Apr 26 13:26:33 CEST 2011


On Monday 25 April 2011 20:49:34 Jonathan Hartley wrote:
> 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/
> > 
> > Cheers,
> > 
> > Drea
> 
> Stealing this from Casey Duncan's recent post to the Grease
> users list:
> 
> 
> - (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
Jonathan,

Thank you for a nice and extensive list of references. To 
clarify my position - surprisingly, speed is not an issue- I've 
programmed a matrix in pure python (3, but mainly iwth python 2 
syntax) and found that inversion was quite fast enough for my 
requirements.  

Good vector algebra is necessary for 3 D frame analysis, so a 
vector package is indicated.  numpy is great, but it is a tool 
like a sledge to drive a nail...

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf



More information about the Python-list mailing list