Entry
How can I hold x,y,z coordinates in a multi-level grid?
Jul 25th, 2000 03:54
unknown unknown, Peter Schneider-Kamp
You can use lists of lists of lists of 3-tuples containing the
coordinates. Adressing is done via repeated indexing.
For example the corners of a unit cube between 0 and 1:
>>> a = [ [ [(0,0,0), (0,0,1)], [(0,1,0), (0,1,1)] ],
... [ [(1,0,0), (1,0,1)], [(1,1,0), (1,1,1)] ] ]
>>> a[0][0][0]
(0, 0, 0)
>>> a[1][0][1]
(1, 0, 1)
>>>
You can also use NumPy. Chances are (if only slight ones) that it will
be included with 2.0
(see PEP 206 http://python.sourceforge.net/peps/pep-0206.html)