One more fix. In quadtree.m, near line 528 (right before %Undo rotation, p=rotate(p,-theta)), add:
% remove duplicate nodes
goodid=find(h~=0);
p=p(goodid,:);
h=h(goodid);
for i=1:length(goodid)
t(t==goodid(i))=i;
end
So that's three places to fix with the comments below:
meshfaces.m, line 203
mytsearch.m, line 69
quadtree.m, line 528 (or thereabouts)
**Correction**
In my tsearch, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));
with:
for k=1:size(t,1)
temp=inpolygon(xi,yi,x(t(k,:)),y(t(k,:)));
i(temp)=k;
end
Then, no need to worry about delaunay triangulations
Tsearch fix courtesy of Rowena Lohman.
tsearch.m needs to be replaced in two locations. First:
in meshfaces.m, line 203 replace:
i=tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));
with:
for j=1:size(th,1)
temp=inpolygon(p(:,1),p(:,2),ph(th(j,:),1),ph(th(j,:),2));
i(temp)=j;
end
In mytsearch.m line 69, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));
with
t = DelaunayTri([x y]);
i(j)= pointLocation(t,[xi(j) yi(j)]);
This uses DelaunayTri which is being fazed out, but delaunayTriangulation can be equally used
Comment only