How can I extrude a 2D patch?

5 views (last 30 days)
Radu Andrei Matei
Radu Andrei Matei on 21 Jun 2022
Commented: Radu Andrei Matei on 21 Jun 2022
Hi, my objective is to have a gear profile like the one below extruded so that I can then convert the 3D gear into a STL file and send it to a 3D printer.
What I've tried to do, as the above are only discrete points, is to triangulate the surface using the delaunay function. That gave me the following result, which is of course bad:
By applying example 6 from https://www.mathworks.com/help/matlab/math/creating-and-editing-delaunay-triangulations.html I managed to get something like this, which is perfect:
The red gear was made with the delaunayTriangulation function with arguments (x,y,C) and eliminating all the triangles outside the gear profile. What I don't really get is how to create another identical patch but with different z coordinates and then join them together to get a 3D gear. I've been able to do it with the 3D delaunay function but what I get is an extrusion of the blue gear, like this:
Is there a way to filter out the triangles in the 3D triangulation outside the gear profile or to extrude the 2D red patch?
Thank you in advance guys :)
  2 Comments
KSSV
KSSV on 21 Jun 2022
Attach your data and code.
Radu Andrei Matei
Radu Andrei Matei on 21 Jun 2022
Hi, I'm going to attach the part of the code with which I do what I posted in my question. pointsPinion is a Nx3 matrix in which the first col contains x coords, the second y coords and the third z coords of the gear profile points. N depends on gear size. I'm gonna attach an example pointsPinion matrix in a txt file.
% This is from example 6 I mentioned. Idk how but it does what I want
nump = numel(app.pointsPinion(:,1));
C = [(1:(nump-1))' (2:nump)'; nump 1];
% This is the 2D constrained delaunay triangulation
dt = delaunayTriangulation(app.pointsPinion(:,1),app.pointsPinion(:,2),C);
% This is the unconstrained 3D delaunay triangulation
DT = delaunayTriangulation([app.pointsPinion(:,1);app.pointsPinion(:,1)],[app.pointsPinion(:,2);app.pointsPinion(:,2)],[app.pointsPinion(:,3);app.pointsPinion(:,3)+app.optiTrans.b]);
% What I do in DT is vertically concatenate two pointsPinion matrices, one with z = 0 and one with z = thickness
figure
tetramesh(DT) % Representing the 3D delaunay triangulation (bad 3D gear)
io = isInterior(dt); % Filter for points outside gear profile
patch('Faces',dt(io,:),'Vertices',dt.Points,'FaceColor','r') % This draws the red gear

Sign in to comment.

Answers (0)

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!