I am new to Mathematica and I am currently in need of some help with creating a neighboring list of triangles for a given triangulation and finding the path to the triangle containing the random point and constructing a tile. So basically, this problem involves the Delaunay Triangulation. I can generate the triangles usingDelaunayMesh
but I can't find the neighboring triangles, the path to the triangle containing the random point, and construct the tile. This is what I have so far.
(* Number of data points *)
numpts = 5;
(* Test data set *)
pts = {{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0.3, 0.4}};
dmesh = DelaunayMesh[pts];
(* Extract the triangle list from the Delaunay triangulation *)
tris = MeshCells[dmesh, 2];
numtris = Length[tris];
(* This demonstrates how to access the pts from the tris list *)
Print["Number of triangles numtris = ", numtris];
Do[
Print["Tri ", i,
" v1=", pts[[tris[[i, 1, 1]]]],
" v2=", pts[[tris[[i, 1, 2]]]],
" v3 = ", pts[[tris[[i, 1, 3]]]]],
{i, 1, numtris}
];
(* Data structure to hold neighbor data *)
nghbrs = Table[{0, 0, 0}, {i, 1, numtris}];
I want to use do loops to find the neighboring list of triangles and the path but I don't know what to enter. Can anyone please help me by showing me what code (I would prefer simple coding as I am still new to this programming language) to enter in the do loops? I would definitely appreciate all the help I can get. Thank you.