create offset for stl file?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I need a solution to add an offset to a stl geometry. 
This is my original object:

what it should look like after adding the offset (that's done with the CAD program):

What I've tried so far:
- with the function stlread I import the part (.stl file) in Matlab 
- this gives me the verticies and faces of the .stl 
- with the function STLVertexNormals I calculate the normal vectors for each vector
- I add them to the original vectors weighted with the offset value
clear all
close all 
clc
stl_part = 'Model.stl'; 
[F, V, N] = stlread(stl_part);  % import stl 
[Vn] = STLVertexNormals(F, V);  % calculate vertex normals
offset = 5;                     % offset value
V_new(:,1) = V(:,1) + offset * Vn(:,1);     % new vertices
V_new(:,2) = V(:,2) + offset * Vn(:,2);     % new vertices
V_new(:,3) = V(:,3) + offset * Vn(:,3);     % new vertices
figure(1)       % plot
subplot(1,2,1)
trisurf(F, V(:,1), V(:,2), V(:,3),'FaceLighting','gouraud','Facecolor','black','FaceAlpha',.1,'EdgeColor','black');
view(90,0)
axis equal 
xlim([-25 25])
ylim([-25 25])
zlim([-10 50])
subplot(1,2,2)
trisurf(F, V_new(:,1), V_new(:,2), V_new(:,3),'FaceLighting','gouraud','Facecolor','black','FaceAlpha',.1,'EdgeColor','black');
view(90,0)
axis equal 
xlim([-25 25])
ylim([-25 25])
zlim([-10 50])
But the result is not what I had in mind:

Can anyone help?
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!