Show 3D model
Models composed of triangle meshes are commonly used in art, engineering, and medical CAD for representing 3D objects. These models consist of a series of triangles in 3D space, sometimes also including colors. Plotting them is not difficult, but it is tedious because the structures are composed of faces (triangles) are defined as indices into vertices (3D points). I wrote the function 'show_model' as a simple plot tool analogous to 'plot'. It can handle variable arguments in to specify transparency, face color, and line style. It returns a handle to the patch object that is created.
Usage:
h = show_model(model,varargin)
Example (with 2d triangles):
model.v = [2 4; ... % x-y coords
2 8; ...
8 4; ...
8 0; ...
0 4; ...
2 6; ...
2 2; ...
4 2; ...
4 0; ...
5 2; ...
5 0 ];
% order in which vertices are joined to form triangles
model.f = [1 2 3; ...
1 3 4; ...
5 6 1; ...
7 8 9; ...
11 10 4];
model.c=[zeros(size(model.v,1),3)];
show_model(model)
Citar como
Francis Esmonde-White (2024). Show 3D model (https://www.mathworks.com/matlabcentral/fileexchange/31375-show-3d-model), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
- MATLAB > Language Fundamentals >
- Physical Modeling > Simscape Multibody > Simulation and Analysis >
- MATLAB > Graphics > Formatting and Annotation > 3-D Scene Control > Lighting, Transparency, and Shading >
Etiquetas
Agradecimientos
Inspirado por: Binary STL file reader, Patch Slim (patchslim.m)
Inspiración para: Generate U3D files from STL models for making multilayer 3D PDF figures
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0.0 |