From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Inscribed triangle in delaunay trianglation mesh
Date: Wed, 2 Jun 2010 19:10:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 36
Message-ID: <hu6aat$dn9$>
References: <ue7Nn.130988$0M5.97947@newsfe07.iad> <>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1275505821 14057 (2 Jun 2010 19:10:21 GMT)
NNTP-Posting-Date: Wed, 2 Jun 2010 19:10:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:641582

ZEESHAN MOHIUDDIN <> wrote in message <>...
> for i=1:length(tri)
>     for j=1:3 
>     X(i,j)=x(tri(i,j));
>     Y(i,j)=y(tri(i,j));
> end
> end
> it gives me two different matrices of x and y co ordinates of each triangle of delaunay. Now I want to apply the methodology proposed by  Roger.  Can you help me to write this. 
> His methodology is as follows:
> " If the vertices of a triangle are three-element vectors P1, P2, P3, then with t a number between 0 and 1 do this:"
> P0 = (P1+P2+P3)/3;
> Q1 = t*P1+(1-t)*P0;
> Q2 = t*P2+(1-t)*P0;
> Q3 = t*P3+(1-t)*P0;
> many Thanks,
> Zeeshan

  Starting with your X and Y arrays above, it could go like this:

 t = rand; % <-- Or however you want to make a random no. between 0 and 1
 P0 = [sum(X,2),sum(Y,2)]/3;
 Q1 = t*[X(:,1),Y(:,1)]+(1-t)*P0;
 Q2 = t*[X(:,2),Y(:,2)]+(1-t)*P0;
 Q3 = t*[X(:,3),Y(:,3)]+(1-t)*P0;

Each row of the arrays Q1, Q2, and Q3 has the x, y coordinates in their two columns for the three vertices, respectively, of the corresponding inner triangle.  You can therefore use these directly to draw those triangles.

  By the way, earlier you used randn to generate random t's.  That doesn't work because the output of randn is not restricted to lie between 0 and 1.  You could get wild triangles that no longer lie inside the delaunay triangles.

Roger Stafford