[SciPy-User] Scipy.spatial.Delaunay

Daniel Lepage dplepage at gmail.com
Wed Mar 16 15:40:57 EDT 2011


Your points are 3 dimensional, and so Delaunay
provides a 3D triangulation where each element is a tetrahedron. Each
tetrahedron has four vertices and up to four neighboring tetrahedra.

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:

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]))


-- 
Dan Lepage


On Wed, Mar 16, 2011 at 3:22 PM, Dan Richards <D.Richards at mmu.ac.uk> wrote:
> Hi Pauli,
>
> Thanks for your quick reply, I really appreciate the help.
>
> I am still a little confused as to how the points, vertices and neighbors
> relate to one another. Perhaps I can explain how I understand them and you
> can correct me?
>
> When I type x.vertices I get an array that has values for each index:
>>>>x.vertices
> array([[6, 4, 5, 9],
>       [8, 6, 4, 5],
>       [8, 1, 4, 7],
>       [8, 1, 6, 4],
>       [3, 6, 4, 9]...])
>
> Do these numbers [w,x,y,z] represent a triangulation whereby the connections
> are as follows?:
>

> w-x
> x-y
> y-z
> w-y
> w-z
>
> Your code did seem to work well, although I added an extra line which I
> assume should have been there?
>
> edges = []
> for i in xrange(x.nsimplex):
>        edges.append((x.vertices[i,0], x.vertices[i,1]))
>        edges.append((x.vertices[i,1], x.vertices[i,2]))
>        edges.append((x.vertices[i,2], x.vertices[i,3])) # New line here
>        edges.append((x.vertices[i,3], x.vertices[i,0]))
>
> The confusion on my part is that I expected the vertices to hold three
> indices relating to the points of a triangle so I am confused as to how to
> interpret the four values?
>
> Equally with the neighbors, could you tell me what the four indices define?
>>>>x.neighbors
> array([[-1, -1,  1,  6],
>       [ 0,  2, 54,  9],
>       [-1,  1, 19,  4],
>       [12, 27, 31, 10],
>       [ 2,  5, 13, 44]...])
>
> Many Thanks,
> Dan
>
>
>
>
>
> The edges are recorded in the `vertices` array, which contains indices of
> the points making up each triangle. The overall structure is recorded
> `neighbors`.
>
> This is maybe easiest to explain in code. The set of edges is:
>
>        edges = []
>        for i in xrange(x.nsimplex):
>            edges.append((x.vertices[i,0], x.vertices[i,1]))
>            edges.append((x.vertices[i,1], x.vertices[i,2]))
>            edges.append((x.vertices[i,2], x.vertices[i,0]))
>
> This however counts each edge multiple times. To get around, that:
>
>        edges = []
>        for i in xrange(x.nsimplex):
>            if i > x.neighbors[i,2]:
>                edges.append((x.vertices[i,0], x.vertices[i,1]))
>            if i > x.neighbors[i,0]:
>                edges.append((x.vertices[i,1], x.vertices[i,2]))
>            if i > x.neighbors[i,1]:
>                edges.append((x.vertices[i,2], x.vertices[i,0]))
>
> This counts each edge only once. Note how the `neighbors` array relates
> to `vertices`: its j-th entry gives the neighboring triangle on the
> other side of the edge formed that remains after the j-th vertex is
> removed from the triangle.
>
> --
> Pauli Virtanen
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
> "Before acting on this email or opening any attachments you should read the Manchester Metropolitan University email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer "
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list