필터 지우기
필터 지우기

How to color triplot faces?

조회 수: 9 (최근 30일)
Manar Al Asad
Manar Al Asad 2020년 8월 26일
답변: Nicolas Hadjittoouli 2023년 6월 21일
I have a 3D DTM in the form of triangulation (has faces and vertices) where the vertices coordinates are in cartesian coordinates (X,Y,Z). I would like to plot the DTM colored based on the radial position of each point.
In 3D this looks like the following, where r1 is a structure that has 2 fields: facets which a connectivity list, and vertices which is the point coordinates:
llr1(:,1),llr1(:,2),llr1(:,3)] = cart2sph(r1.vertices(:,1),...
r1.vertices(:,2),r1.vertices(:,3)); % convert to spherical coordinates to get radial position
llr1(:,1) = rad2deg(llr1(:,1)); % convert to degrees
llr1(:,2) = rad2deg(llr1(:,2)); % convert to degrees
figure(1)
trisurf(r1.obj.facets,r1.obj.vertices(:,1),r1.obj.vertices(:,2),...
r1.obj.vertices(:,3),llr1(:,3))
Now I would like to do the same thing in 2D simple cylindrical projection
figure(2);
triplot(r1.obj.facets,llr1(:,1),llr1(:,2))
gives me a line map with the right connectivity
but now I would like to color the faces in the 2d plot. Has anyone encountered this problem before and has a simple solution to it?

답변 (2개)

Cris LaPierre
Cris LaPierre 2020년 8월 27일
I believe a triplot is a line plot. You can color the lines and markers (vertices), but there are no faces to color.

Nicolas Hadjittoouli
Nicolas Hadjittoouli 2023년 6월 21일
I managed to go around the problem by saving the points and connectivity list of triplot and I inserted an extra column of ones(m, 1) and use triangulation function to re-create the triangulation. Assuming that m is the length of your points.
For example:
h = triplot(X);
C = h.ConnectivityList;
P = h.Points;
P = [P ones(size(P,1), 1)]
TO = triangulation(C, P);
trisurf(TO);
And after that you can use trisurf as usual to insert face colors.

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by