Image rotation using patch for plot.
조회 수: 8 (최근 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!