How could I create stl file based on the ellipsoid command?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daniel Chou
am 21 Dez. 2020
Bearbeitet: DGM
am 12 Jul. 2025
I try several methods to write an stl file based on the ellipsoid geometry.
But I haven't find way to successfully do it.
Following is my code
clear
clc
close all
[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
s=surf(x,y,z)
p=surf2patch(s)
%Extract faces and vertices from structure p
pf=p.faces
pv=p.vertices
tr=triangulation(pf,pv)
stlwrite(tr,'ell.stl')
The message ''Tetrahedron triangulation is not supported.'' appears, I know I could use ''boundaryFacets'' command to solve this problem, but I don't know how to create an alphaShape of ellipsoid.
Could anyone gives me a hint?
0 Kommentare
Akzeptierte Antwort
Aditya Patil
am 24 Dez. 2020
stlwrite only support triangles.
shp = alphaShape(tr.Points)
[F,P] = freeBoundary(tr)
trNew = triangulation(F,P)
stlwrite(trNew, "freeboundary.stl")
2 Kommentare
DGM
am 12 Jul. 2025
Bearbeitet: DGM
am 12 Jul. 2025
It's not necessary to use alphashape and risk complications with maintaining non-convex features. You need a triangular surface mesh. By default, surf2patch() returns a quadrilateral surface mesh, not a tetrahedral volume mesh. From the perspective of stlwrite(), the difference is ambiguous. Elements with four vertices might be quads, or they might be tetrahedrons (really, I suppose they tend to be tetrahedrons either way, since surf "quads" aren't always planar). Regardless of what stlwrite() assumes they're supposed to be, a standard STL doesn't contain either, so the difference is moot.
If you want triangles, ask for triangles.
[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
s=surf(x,y,z);
p=surf2patch(s,'triangles');
%Extract faces and vertices from structure p
pf=p.faces;
pv=p.vertices;
tr=triangulation(pf,pv) % elements have three vertices, not four
stlwrite(tr,'ell.stl') % no error
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Bounding Regions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


