Image rotation using patch for plot.
13 次查看(过去 30 天)
显示 更早的评论
I need manipulate matrix vert for creat a rotation in z axis.
I'm transpose this matrix and multiply for matrix rotation... Transpose again and try exclude the four columm for using this in patch function.
clf;
figure(1);
format compact
h(1) = axes('Position',[0.2 0.2 0.6 0.6]);
vert = [1 1 -1 1;
-1 1 -1 1;
-1 1 1 1;
1 1 1 1;
-1 -1 1 1;
1 -1 1 1;
1 -1 -1 1;
-1 -1 -1 1];
fac = [1 2 3 4;
4 3 5 6;
6 7 8 5;
1 2 8 7;
6 7 1 4;
2 3 5 8];
theta = 30;
rotacaoz = [cos(theta) -sin(theta) 0 0;
sin(theta) cos(theta) 0 0;
0 0 1 0;
0 0 0 1];
vertices = vert';
vertices = vertices * rotacaoz;
vertices = vertices';
vertices(:,[3 4])=[]
patch('Faces',fac,'Vertices',vertices,'FaceColor','c'); % patch function
axis([-1, 1, -1, 1, -1, 1]);
axis equal;
hold on;
material metal;
alpha('color');
alphamap('rampdown');
view(3);
0 个评论
回答(1 个)
Walter Roberson
2014-2-10
If what you care about is the output appearance and not so much how you got there, then you may wish to consider putting the patch of the original vertices into a hgtransform group, and using makehgtransform to build the rotation matrices.
If you are not wanting to display the axes, then you may wish to consider using camorbit()
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!