Delete triangulations outside the outline polygon and z value manipulation

조회 수: 5 (최근 30일)
zzzzz Sap
zzzzz Sap 2011년 4월 4일
댓글: Yonni f 2022년 10월 26일
I have an outline polygon traced using impoly, over an image of an outline. When I triangulate it using delaunay command, triangulations extend outside the polygon. how to delete these unwanted triangles, and then manipulate the z values of the polygon, to change its orientation? I'm using Matlab R2008a

답변 (1개)

Paul Rötzer
Paul Rötzer 2022년 10월 17일
I know the answer comes very late but i struggled with the same problem today.
For newer version of matlab the following should work:
% P contains the points on outline of polyshape
polyin = polyshape(P);
EdgeConstraint = [(1:length(P))' [(2:length(P))'; 1]];
DT = delaunayTriangulation(P, EdgeConstraint)
%% remove outside triangles
C = incenter(DT);
TF = isinterior(polyin, C);
InsideTriangles = DT.ConnectivityList(TF, :);
  댓글 수: 1
Yonni f
Yonni f 2022년 10월 26일
Amazing. I was just strugging on the same thing and I found your response to a decade old post.
To ellaborate a bit more on Paul's answer, I edited the triangulation by calling a new structure called dts and then removing the connections outside the border:
dts = struct('Points', DT.Points, 'ConnectivityList', DT.ConnectivityList);
dts.ConnectivityList(~TF, :) = [];
x=triangulation(dts.ConnectivityList, dts.Points);
triplot(x);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by