Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delaunay Triangulation: How to color specific triangles in a triplot?

385 views
Skip to first unread message

Liana

unread,
Mar 21, 2011, 1:01:05 AM3/21/11
to
Hello All,

dt = DelaunayTri(X, Y, C);

I have a column vector 'tri', where each number corresponds to triangle ID in dt.Triangulation, e.g.:
tri(:,1) = [1; 12; 14; 16]; % corresponds to dt.Triangulation(1,:), dt.Triangulation(12,:), dt.Triangulation(14,:), etc.

Now I'd like to create a triplot, where only triangles specified in 'tri' would have a blue background. How could I do that?

Thank you for all your help!

Bruno Luong

unread,
Mar 21, 2011, 4:16:04 AM3/21/11
to
"Liana" wrote in message <im6m2h$msa$1...@fred.mathworks.com>...

help patch
help fill

Bruno

Liana

unread,
Mar 21, 2011, 1:55:05 PM3/21/11
to
"Bruno Luong" <b.l...@fogale.findmycountry> wrote in message <im71g4$sq5$1...@fred.mathworks.com>...

Hi Bruno!

Thank you. I'm trying the following:

% Get vertices of each triangle in 'tri', where k is total number of triangles in 'tri'
V1t = x(handles.dt(tri(1:k,1),1),:);
V2t = x(handles.dt(tri(1:k,1),2),:);
V3t = x(handles.dt(tri(1:k,1),3),:);
Vertices = V1t + V2t + V3t;

fill(Vertices(1:k,1), Vertices(1:k,2), 'b')

However, this code does not provide a correct result. Thanks for any help.

Bruno Luong

unread,
Mar 21, 2011, 2:17:05 PM3/21/11
to
Here is an example:

x =randn(100,1);
y =randn(100,1);
dt = DelaunayTri(x,y)
T = dt.Triangulation;
patch(x(T)',y(T)','b','EdgeColor','w');

Please adapt it to you need.

Bruno

Liana

unread,
Mar 21, 2011, 3:13:08 PM3/21/11
to
"Bruno Luong" <b.l...@fogale.findmycountry> wrote in message <im84n1$cgo$1...@fred.mathworks.com>...

Thanks a lot! One more question just to be sure that I am on the right way. I have a constrained Delaunay Triangulation specified as follows:
dt = DelaunayTri(vertices,edges);
isInside = inOutStatus(dt);
faces = dt(isInside,:);
Do I understand correctly that the logic of 'patch' will remain the same?

Liana

unread,
Mar 21, 2011, 3:43:05 PM3/21/11
to
"Liana" wrote in message <im8804$bgg$1...@fred.mathworks.com>...

Your code does exactly what I need, if Delaunay Triangulation is specified by x & y:
x =randn(100,1); y =randn(100,1); dt = DelaunayTri(x,y);
However, I still can't figure it out for a constrained DT...

Liana

unread,
Mar 21, 2011, 9:50:05 PM3/21/11
to
"Liana" wrote in message <im89o9$cs0$1...@fred.mathworks.com>...

I solved this problem. It was quite simple. It seems that I just had incomplete understanding of 'dt' structure.

0 new messages