How to obtain normals from faces?
6 views (last 30 days)
Show older comments
Hello, I would like to know if there is a way to obtain the normals of some given Faces. The Faces are defined by an stl file. I am using Matlab R2012b. Thank you for your help!
0 Comments
Answers (1)
DGM
on 4 Apr 2025
Edited: DGM
on 4 Apr 2025
The easy way would be to use the triangulation class, or since we're pre-R2013a, use TriRep(). The following example was tested in R2009b.
unzip saddleblock.stl.zip % needed for the forum
% you got F,V data in MATLAB somehow.
% this is from FEX #51200 and was available in early 2015,
% so it's period-correct, or at least plausible.
[V F] = stlRead('saddleblock.stl');
% since we're in R2012b, we're using TriRep().
% after R2013a, we can just use triangulation().
T = TriRep(F,V);
fn = faceNormals(T);
c = incenters(T);
% display it all
patch('faces',F,'vertices',V,'facecolor','w','edgecolor','k'); hold on
quiver3(c(:,1),c(:,2),c(:,3),fn(:,1),fn(:,2),fn(:,3),'linewidth',2);
view(3); camlight; view(10,33)
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!