# [SciPy-User] Scipy.spatial.Delaunay

Pauli Virtanen pav@iki...
Wed Mar 16 17:02:31 CDT 2011

```Wed, 16 Mar 2011 15:40:57 -0400, Daniel Lepage wrote:
[clip]
> Pauli's example has fewer connections than you expect because it assumes
> a 2D triangulation. In the 3D case, you should have six lines of code
> connect each of the four vertices to each other:

Yes, sorry, I didn't read the original mail carefully enough. For 3D,
each tetrahedron has 6 edges, and they can be found as Daniel shows:

> edges = []
> for i in xrange(x.nsimplex):
>        edges.append((x.vertices[i,0], x.vertices[i,1]))
>        edges.append((x.vertices[i,0], x.vertices[i,2]))
>        edges.append((x.vertices[i,0], x.vertices[i,3]))
>        edges.append((x.vertices[i,1], x.vertices[i,2]))
>        edges.append((x.vertices[i,1], x.vertices[i,3]))
>        edges.append((x.vertices[i,2], x.vertices[i,3]))

If you want each edge to appear only once, the trick of using
x.neighbours will not work in 3D, since ndim - 1 != 1. So a brute
force algorithm needs to be used, for example detecting duplicates
while processing, or by removing them afterwards. (This information
is not available from Qhull.)

If you want to write something yourself using Cython, this may give
some ideas on how to proceed:

https://github.com/pv/scipy-work/blob/enh%2Finterpnd-smooth/scipy/spatial/qhull.pyx#L969

Note that it'll need some adaptation.

--
Pauli Virtanen

```