Turning triangulation data into 3D spatial matrix

20 ビュー (過去 30 日間)
lunalara
lunalara 2020 年 8 月 3 日
コメント済み: Cris LaPierre 2020 年 8 月 4 日
Hello all,
I am trying to import an STL file (or some similar 3D model file format) and turn the information into a 3D matrix specifying 'presence' of the object.
For example, if considering the solid geometry as in the attached image, each plane (1-4 etc) would represent a 2D logical matrix, with '1' specifying the presence of the surface within that plane. These planes will eventually represent equally-spaced, planar locations in the out-of-plane direction.
I have successfully imported the geometry as a triangulation, and am able to see the surface in 3-D space when plotting with trisurf(), but am wondering if anyone has thoughts on how to convert/consider the triangulation data as a solid object to work with it in the aforementioned manner?
The actual geometries that will be considered are much more complex than the one mentioned here (with holes etc), but I thought the block would be a good place to start.
*Note: I know this is a weird problem, and any thoughts are greatly appreciated. :)
**Note: I tried to upload the .stl, but the format is unsupported. I would be happy to supply if requested.
Thanks in advance!
filename = [path '/TestGeom.stl'];
>> stlread(filename)
ans =
triangulation with properties:
Points: [10×3 double]
ConnectivityList: [16×3 double]
>> trisurf(ans)

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 8 月 4 日
I would see if the inpolygon function can be used here. It works for 2D data, but with some creativity, you may be able to get it to work. It is able to detect points between two polygons, a necessary feature for geometries that might have holes.
  3 件のコメント
lunalara
lunalara 2020 年 8 月 4 日
Hi again Cris,
Thanks to your inpolygon advice, I was able to find/utilize this other function inpolyhedron, which works very well for finding points within a 3D space! One might suggest using this function with STL vertices and faces imported via the FEX function stlread (note: this is different from the MATLAB built-in 'stlread', so users should save/call it with a slightly changed title to avoid confusion).
The rest is just defining my X,Y,Z points, but that's a personal problem... ;)
Thank you again for your advice. I wouldn't have found it without you.
Cheers!
Cris LaPierre
Cris LaPierre 2020 年 8 月 4 日
You're welcome. Nice find.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSTL (STereoLithography) についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by