Image rotation using patch for plot.

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);

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 2 月 10 日

0 投票

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()

1 件のコメント

Henrique
Henrique 2014 年 2 月 10 日
I need demonstrate this transformations in my code. My solution depends this.

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 2 月 10 日

コメント済み:

2014 年 2 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by