[SciPy-User] Scipy.spatial.Delaunay
Robert Kern
robert.kern at gmail.com
Wed Mar 16 15:40:22 EDT 2011
On Wed, Mar 16, 2011 at 14:22, 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
And x-z. It's a tetrahedralization, technically. But you probably
don't want to deal with edges. Rather, you usually want to deal with
faces.
w-x-y
x-z-y
w-z-x
w-y-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?
He was showing you the 2D case for triangles. For the 3D case of
tetrahedra, you probably want faces rather than edges.
faces = []
v = x.vertices
for i in xrange(x.nsimplex):
faces.extend([
(v[i,0], v[i,1], v[i,2]),
(v[i,1], v[i,3], v[i,2]),
(v[i,0], v[i,3], v[i,1]),
(v[i,0], v[i,2], v[i,3]),
])
> 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]...])
Each is the index into x.vertices of the simplex that is adjacent to
the face opposite the given point. This index is -1 when that face is
on the outer boundary. The first simplex has these neighbors:
[-1, -1, 1, 6]
This means that the face opposite point w (x-y-z) is on the outer
boundary. The face opposite point y (w-x-z) adjoins the simplex given
by x.vertices[1], and so on.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list