From: Raphael on 16 Apr 2010 05:17 Hello, Imagine I have a n*3 matrix Positions of cell positions in space. I did the following to extract the Delaunay triangulation and the neighbourhood relationships implied by it (0 if stranger, 1 if neighbour). Is there a way to do this faster ? What if I wanted to take away unlikely relationships, e.g. between cells that are further than a certain threshold ? Thank you very much in advance, Raphaƫl Delaunay=delaunayn(Positions,[]); Neigh=sparse(Delaunay(:,[1 1 1 2 2 3]),Delaunay(:,[2 3 4 3 4 4]),1,n,n); % 1 is a neighbour of 2, 3, 4 ; 2 of 3, 4 ; 3 of 4. Neigh = Neigh' + Neigh + sparse((1:n)',(1:n)',1); % the last part is to ensure cell i is neighbour with itself Neigh = logical(Neigh);
From: Rune Allnor on 16 Apr 2010 05:43 On 16 apr, 11:17, "Raphael " <raphael.kel...(a)gmail.com> wrote: > Hello, > > Imagine I have a n*3 matrix Positions of cell positions in space. I did the following to extract the Delaunay triangulation and the neighbourhood relationships implied by it (0 if stranger, 1 if neighbour). Is there a way to do this faster ? Fast operations in tesselations and triangulations are difficult. You need to have access to a lot of internal variables in the triangulation routine. Don't expect speed if you do everything in the matlab domain. Rune
|
Pages: 1 Prev: Logical indexing in matrices Next: colors for individual contour lines |