what do people use for 2D coordinates?

Raymond Hettinger vze4rx4y at verizon.net
Fri Aug 1 19:43:29 EDT 2003


"Andy C" <aayycc88 at hotmail.com> wrote in message
news:cf0d8a77.0308011537.5ed232f6 at posting.google.com...
> You could use tuples or complex numbers (seems like a bit of a hack).

For your application, complex numbers seem like a perfect choice.

> I saw somewhere it said that tuples are useful for coordinates.  But I
> haven't found a nice way to add coordinates, since + does
> concatenation on tuples.
>
> Is there a better way than to keep writing (a[0]+b[0], a[1]+b[1])
> instead of just a+b?  (and 2*a instead of (2*a[0], 2*a[1]) ). I know
> there is this NumPy library, but that seems like overkill for what I
> need.  I'm just doing some simple 2D drawing.  I know it would be
> trivial to write my own Point class, but I'm just wondering what other
> people do.  It would be nice if there was some built in module that
> does basic vector math.

See http://users.rcn.com/python/download/python.htm
It has a pure python module for vector math and matrix operations.


Raymond Hettinger











More information about the Python-list mailing list