필터 지우기
필터 지우기

how can I create a unique patch object

조회 수: 2 (최근 30일)
Andrea Gusmara
Andrea Gusmara 2020년 5월 2일
댓글: Andrea Gusmara 2020년 5월 2일
I would like to create a unique object p (patch) so as to preserve some features like faces' color and surface , upon wich i can plot another figures , so as to preserve the previous figures , modifyng only the S.Vertices.
surf=gca;
xlim(surf,[-10 10]);
xlabel('x');
zlim(surf,[-10 10]);
zlabel('z');
ylim(surf,[-10 9]);
ylabel('y');
daspect([1 1 1]);
%first figure
S.Vertices=[1,1,1;4,1,1;4,4,1;1,4,1; 1,1,4;4,1,4;4,4,4;1,4,4];
S.faces=[1,2,3,4;1,2,6,5;3,2,6,7;4,3,7,8;4,1,5,8;5,6,7,8];
p=patch(gca,S);
p.FaceVertexCData=[1 0 0; 0 1 0 ; 0 0 1 ; 0 1 1 ; 1 0 1 ; 1 1 0 ];
p.FaceColor="flat";
%simple object rotation
theta=pi/2;
mry=[ cos(theta) 0 sin(theta) ;
0 1 0 ;
-sin(theta) 0 cos(theta)];
S.Vertices=mry*S.Vertices';
S.Vertices=S.Vertices';
% second figure
p=patch(S);
p.FaceVertexCData=[1 0 0; 0 1 0 ; 0 0 1 ; 0 1 1 ; 1 0 1 ; 1 1 0 ];
p.FaceColor="flat";
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 5월 2일
copyobj() perhaps?
Make a copy of the patch into the current axes, and modify the vertices in the copy.
Andrea Gusmara
Andrea Gusmara 2020년 5월 2일
thank you very much for your reply but i've found an alternative solution using directly
S.Vertices = [S.Vertices ; newVertices];

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by