Why does "delaunay" sometimes give a different result from "delaunayTriangulation"?

3 views (last 30 days)
I have a file containing a set of x,y,z points which describe the surface of a 10 pence coin. I wish to triangulate the data. I tried Matlab's in-built "delaunay" function and the results are satisfactory. However, if I use Matlab's in-built "delaunayTriangulation" function I get a completely different result. Can you suggest possible reasons for this difference? For visualisation of the problem I have included the script below and I have also attached a .csv file containing a sample of the x,y,z data:
Thanks
fname = 'ten_pence_coin_sample.csv';
data = csvread(fname);
deltaX = 20;
TopThreshold = 37000;
BotThreshold = 8620;
XXXX = 0;
PrevEnc = 0;
x = zeros(length(data(:,1)),1);
for n = 1: length(data(:,1))
if n>1
PrevEnc = data(n-1, 4);
end
Enc = data(n,4);
if Enc>TopThreshold && PrevEnc < TopThreshold
XXXX = XXXX + deltaX;
x(n) = nan;
elseif Enc<BotThreshold && PrevEnc > BotThreshold
XXXX = XXXX + deltaX;
x(n) = nan;
else
x(n) = XXXX;
end
end
z=data(:,2);
z(find(z<0)) = nan;
filt_ind = isnan(z) | isnan(x) ;
z_filt = z ;
x_filt = x ;
y_filt = data(:,4) - min(data(:,4)) ;
z_filt(filt_ind) = [];
x_filt(filt_ind) = [];
y_filt(filt_ind) = [];
DT = delaunay(x_filt,y_filt);
DT2 = delaunayTriangulation(x_filt,y_filt);
figure
trimesh(DT,x_filt,y_filt,z_filt);
figure
trimesh(DT2.ConnectivityList,x_filt,y_filt,z_filt);

Accepted Answer

John D'Errico
John D'Errico on 4 Nov 2015
Edited: John D'Errico on 4 Nov 2015
What is the delaunay triangulation of the unit square? Thus, if we start with the vertices
V = [0 0;0 1;1 0;1 1];
Is there a unique triangulation? I think the answer is clear. There is no unique choice that is better. We might have the pair or triangles
tri1 = [1 2 3;2 3 4]
or we might choose the pair
tri2 = [1 2 4;1 3 4];
Either is as good a choice. Effectively, the difference is only in the diagonal of the square we choose. Two different algorithms might make different choices, and be equally correct in their choice.
In addition, some algorithms resolve issues by making a joggle of the points, a pseudo-random perturbation of points, which can greatly help. However, there you will even find the same algorithm produces non-identical results upon repeated applications.

More Answers (0)

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!