how can I create a unique patch object

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 个评论

copyobj() perhaps?
Make a copy of the patch into the current axes, and modify the vertices in the copy.
thank you very much for your reply but i've found an alternative solution using directly
S.Vertices = [S.Vertices ; newVertices];

请先登录,再进行评论。

回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by