基于Matlab的图像旋转
我需要操纵矩阵顶点来创建z轴上的旋转 我把这个矩阵转置,然后乘上矩阵旋转。。。再次转置并尝试排除四列,以便在修补程序中使用此函数 但有些事情似乎不起作用,消息如下: ???使用==>mtimes时出错 内部矩阵尺寸必须一致 问题是在绘图行中使用[x y z;]的面片函数,但对于矩阵旋转,我需要在列中使用矩阵[x y z 1;]基于Matlab的图像旋转,matlab,image-processing,transformation,matrix-multiplication,Matlab,Image Processing,Transformation,Matrix Multiplication,我需要操纵矩阵顶点来创建z轴上的旋转 我把这个矩阵转置,然后乘上矩阵旋转。。。再次转置并尝试排除四列,以便在修补程序中使用此函数 但有些事情似乎不起作用,消息如下: ???使用==>mtimes时出错 内部矩阵尺寸必须一致 问题是在绘图行中使用[x y z;]的面片函数,但对于矩阵旋转,我需要在列中使用矩阵[x y z 1;] enter code here clf; figure(1); format compact h(1) = axes('Position',[0.2 0.2 0.6
enter code here
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);
对于旋转矩阵R和点p,旋转的点是R*p,而不是p*R 正确:
vertices = rotacaoz*vertices;