Write an STL (ASCII) File in MATLAB || TUTORIAL
Prot04m Prot04m
513 subscribers
3,331 views
0

 Published On Dec 8, 2021

*CORRECTIONS*
Line 28 & 47: unit_norm should be unit_normal.
**
Hopefully the video was clear. This should work for all structured 3D objects (NO point clouds). If you are a little more proficient with programming, you can save computing time and space with a more efficient FOR loop and removing the repeated nodes. The STL file also allows you to store color and material data, which is something I am currently investigating.

I didn't go into detail as to why the STL file is structured the way it is, but basically, you need to list the vertices of each facet in counter-clockwise direction so that the normal is in the outward direction; this is important when calculating volumes and certain CFD codes.

All the geometries were exported using the code in this video. If you want to learn how to generate 3D objects, check my playlist linked below.

Playlist: Structured 3D OBJECTS in MATLAB
   • MATLAB: Structured 3D Geometries  

Playlist: FILE FORMATS in MATLAB
   • MATLAB: File Formats  

fprintf() documentation:
https://www.mathworks.com/help/matlab...
fopen() documentation:
https://www.mathworks.com/help/matlab...
fclose() documentation:
https://www.mathworks.com/help/matlab...

Software: MATLAB 2020b

show more

Share/Embed