I want to rotate and align a 3d mesh model represented in face-vertex form. Transformation of a 3d matrix would have worked if my model was a in point cloud form. I couldn't find a function to convert a face-vertex information to [x y z] point cloud information.
view(-[0 20]);
the above command help to see the image in desired angle but it is not changing the face-vertex values. My 3d object is in .stl format and i used ftread.m function to load it to matlab .
Function to read .stl file
function [fout, vout, cout] = ftread(filename)
% Reads CAD STL ASCII files, which most CAD programs can export.
% Used to create Matlab patches of CAD 3D data.
% Returns a vertex list and face list, for Matlab patch command.
%
% filename = 'hook.stl'; % Example file.
%
fid=fopen(filename, 'r'); %Open the file, assumes STL ASCII format.
if fid == -1
error('File could not be opened, check name or path.')
end
%
% Render files take the form:
%
%solid BLOCK
% color 1.000 1.000 1.000
% facet
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% outer loop
% vertex 5.000000e-01 -5.000000e-01 -5.000000e-01
% vertex -5.000000e-01 -5.000000e-01 -5.000000e-01
% vertex -5.000000e-01 5.000000e-01 -5.000000e-01
% endloop
% endfacet
%
% The first line is object name, then comes multiple facet and vertex lines.
% A color specifier is next, followed by those faces of that color, until
% next color line.
%
CAD_object_name = sscanf(fgetl(fid), '%*s %s'); %CAD object name, if needed.
% %Some STLs have it, some don't.
vnum=0; %Vertex number counter.
report_num=0; %Report the status as we go.
VColor = 0;
%
while feof(fid) == 0 % test for end of file, if not then do stuff
tline = fgetl(fid); % reads a line of data from file.
fword = sscanf(tline, '%s '); % make the line a character string
% Check for color
if strncmpi(fword, 'c',1) == 1; % Checking if a "C"olor line, as "C" is 1st char.
VColor = sscanf(tline, '%*s %f %f %f'); % & if a C, get the RGB color data of the face.
end % Keep this color, until the next color is used.
if strncmpi(fword, 'v',1) == 1; % Checking if a "V"ertex line, as "V" is 1st char.
vnum = vnum + 1; % If a V we count the # of V's
report_num = report_num + 1; % Report a counter, so long files show status
if report_num > 249;
disp(sprintf('Reading vertix num: %d.',vnum));
report_num = 0;
end
v(:,vnum) = sscanf(tline, '%*s %f %f %f'); % & if a V, get the XYZ data of it.
c(:,vnum) = VColor; % A color for each vertex, which will color the faces.
end % we "*s" skip the name "color" and get the data.
end
% Build face list; The vertices are in order, so just number them.
%
fnum = vnum/3; %Number of faces, vnum is number of vertices. STL is triangles.
flist = 1:vnum; %Face list of vertices, all in order.
F = reshape(flist, 3,fnum); %Make a "3 by fnum" matrix of face list data.
%
% Return the faces and vertexs.
%
fout = F'; %Orients the array for direct use in patch.
vout = v'; % "
cout = c';
%
fclose(fid);

MATLABmight not be the best tool for this job. Have you considered using a CAD program, e.g. SolidWorks?voutrot = vout * r, whereris a 3x3 rotation matrix that you would define based on the rotation angle, as @WhiteViking suggested.