필터 지우기
필터 지우기

3D Polygon with varying z height does not fill correctly

조회 수: 2 (최근 30일)
Julia
Julia 2020년 5월 11일
Hello!
I am really sorry as this seems such a silly question but I just don't seem to be able to get my 3D polygon right - the filling of the polygon cuts weirdly across an area where the z values vary a lot.
I attach the variable "M" where the first, second and third column correspond to x, y and z coordinates of 34 points (34 rows). This first 17 and the last 17 rows are vaguely parallel to each other (plotted in red and green in figure 1). I would like to fill the space between the parallel lines in such a way that the result contains panes like illustrated by the black connecting lines in figure 1. However, the result I get cuts strangely across the areas where the z values go up and down (see figure 2).
I know I could achieve this by just plotting 16 small polygons with 4 corners but it would much better if it could be achieved with a single shape as I will need a few hundred of these shapes and thousands of small polygons seem to make the 3D plot hard to rotate...
It would be fantastic if someone could help me with this problem!
Best,
Julia
This is the code I have used for the figures:
figure(1)
hold on
plot3(M(1:17,1),M(1:17,2),M(1:17,3),'r')
plot3(M(18:34,1),M(18:34,2),M(18:34,3),'g')
% Add connecting lines to illustrate desired shape
M2 = M(1:17,:);
M3 = flipud(M(18:34,:));
for i = 1:17
plot3([M2(i,1) M3(i,1)],[M2(i,2) M3(i,2)],[M2(i,3) M3(i,3)],'k')
end
figure(2)
polygon = patch(M(:,1),M(:,2),M(:,3),'b')

답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by