matlab旋转矩阵来旋转三维模型+meshlab旋转模型+matlab基础常用操作
matlab旋转矩阵实战:
①点云,按照旋转矩阵后旋转(mesh的话(例如.obj),顶点v按照这个旋转,再把原face加入到旋转后的顶点结果中就行了)
(本文matlab2017才可以读取.pcd文件,也可以读入普通.xyz,.txt文件等,然后作为矩阵读入):
ptCloud = pcread('C:/Users/du/Desktop/c3.pcd');
% pcshow(ptCloud);
POINT3d=ptCloud.Location;
% % 以下是模型旋转(例如点云绕x轴旋转180°):
shape=POINT3d;
shape=shape';
Rmatrix = rotz(0)*roty(0)*rotx(180);
shape= Rmatrix*shape ;
shape=shape';
% %写入文件
fid=fopen('C:/Users/du/Desktop/x.xyz','wt');
[m,n]=size(shape);
for i=1:1:m
for j=1:1:n
if j==n
fprintf(fid,'%g\n',shape(i,j));
else
fprintf(fid,'%g\t',shape(i,j));
end
end
end
fclose(fid);
②meshlab旋转三维模型:
原模型
然后meshlab里面选择:Filters--Normal...orientation--..Rotate,里面设置想要的旋转矩阵参数就行了:
旋转后得到:
然后file--export,保存该模型到某目录即可。
③matlab基本操作:
矩阵与数组定义,赋值,逆矩阵等:
http://gaunthan.leanote.com/post/Matlab-%E7%9F%A9%E9%98%B5%E4%B8%8E%E6%95%B0%E7%BB%84
http://blog.****.net/crystal_avast/article/details/7074172