I have to triangulate a simple unit triangle (a half of the unit square) with uniform grid. Using DelaunayTri class the triangulation makes a few more triangles on the hypotenuse. This is a straight line the triangle is not supposed to be there. I was able to avoid the problem just for a few specific numbers but not in general.
How I can fix it ??
See example:
function bary(n)
% works nice for n=3,5,9,17; not for any
u=linspace(0,1,n);
v=linspace(0,1,n);
uv=[];
for j=1:n
for i=1:nj+1
x=[u(i) v(j)];
uv=[uv; x];
end
end
% Triangulation of the barycentric coordinates
dt=DelaunayTri(uv(:,1),uv(:,2));
T=dt(:,:);
Tuv=delaunay(uv(:,1),uv(:,2));
figure(1);clf;
scatter(uv(:,1),uv(:,2))
hold on
length(T)
length(Tuv)
triplot(dt,'red')
% Labels
x=uv(:,1);y=uv(:,2);
hold on
vxlabels = arrayfun(@(n) {sprintf('P%d', n)}, (1:length(x))');
Hpl = text(x, y+0.03, vxlabels, 'FontWeight', 'bold', 'HorizontalAlignment',...
'center', 'BackgroundColor', 'none');
ic = incenters(dt);
numtri = size(dt,1);
trilabels = arrayfun(@(x) {sprintf('T%d', x)}, (1:numtri)');
Htl = text(ic(:,1), ic(:,2), trilabels, 'FontWeight', 'bold', ...
'HorizontalAlignment', 'center', 'Color', 'red');
hold off
The delaunay command works fine but I want to use the DlelaunayTri object commands. Should I use delaunay + TriRep to create one ??
