Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problem with triangulation using DelaunayTri Class

Subject: Problem with triangulation using DelaunayTri Class

From: Jacek W

Date: 9 Dec, 2009 13:23:01

Message: 1 of 2

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
 for j=1:n
      for i=1:n-j+1
         x=[u(i) v(j)];
         uv=[uv; x];
% Triangulation of the barycentric coordinates
    hold on
    % Labels
    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 ??

Subject: Problem with triangulation using DelaunayTri Class

From: Doug

Date: 15 Dec, 2009 16:37:01

Message: 2 of 2

Hi Jacek--
I'm surprised the delaunay function works when DelaunayTri won't because the current version of delaunay calls DelaunayTri. On the other hand, delaunayn seems to be independent code.

Also, I'll add another issue to this thread. I noticed this morning that running DelaunayTri repeatedly on the same data produces *different* triangulation matrices. Actually the matrix members are the same, but their order varies from one run to another. That can be a real problem! My code, for example, uses the triangulation as a mesh for solving Laplace's equation, and with a different triangulation matrix, the solution is quite different. I've implemented a sort after calling DelaunayTri, which fixes the problem.

So a kind request to the folks at Mathworks: please fix up DelaunayTri so that identical inputs produce identical output. Thanks guys!


Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us