Image rotation using patch for plot.
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 10 Feb. 2014
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()
Siehe auch
Kategorien
Mehr zu Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!