Extrude discreate data plot into a 3D space (for 3D printing)

3 visualizaciones (últimos 30 días)
Mat
Mat el 22 de Jul. de 2021
Respondida: Abhinaya Kennedy el 4 de Jun. de 2024
Hi there! MatLab noob here.
I am trying to generate a series of patterns which could be plotted within a 2D cartesian system. From this I would need to extrude the descreate points/ lines to give it some depth such that meshing and slicing would be possible for 3d printing compatability.
I could do this on CAD software, but I need these patterns to be formulated for ease of variable manipulation (depending on the printing parameters) and for increasing the complexity for following patterns.
Something that was expected to be relativly simple has turned nightmarish, please help!
The first is basicaly just a symmetrical grid with discreate points, my atempted code below:
x= [0:0.1:2];
y= [0:0.1:3];
[xq, yq] = meshgrid(x,y); %generate a grid with defined variables
coords = [xq(:) yq(:)]; % Cooridinates of each point in the grid
DT = delaunayTriangulation (coords); % Gnerate a STL mesh of points
hold on;
Tplot = triplot(DT,xq,yq, "LineStyle", "-."); % Plot the mesh
hold off;
%stlwrite(DT,'dotGrid.stl') % Save in STL format
how could I add depth to this? Would it also need a width, maybe a circular geometry instead of a point before extrution? Either way, I'm lost.
The other patterns, are similar in concept, except with contiuous linear and waved lines. Though I'm hoping if I can understand the general gist of this, I may be able to adapt it to the others.
However, any input on any of the mentioned would be highly apprechiated!
Thanks in advance.

Respuestas (1)

Abhinaya Kennedy
Abhinaya Kennedy el 4 de Jun. de 2024
Hi Mat,
  • Start with your 2D grid: Use "meshgrid" to define your x and y coordinates.
  • Add depth:
  • Extrusion: Create a "z" coordinate array for a uniform height or use an array for variations. Combine x, y, and z into a 3D coordinate array. Use "trimesh" (install with "pkg install trimesh") to generate a mesh.
  • Offsetting: Duplicate your points, offset them in z by a desired thickness, and create separate meshes for top and bottom surfaces.
  • Circular geometry: Define a cylinder radius and use functions like "cylinder" or "circle" to create circles at each point instead of using points directly.
  • Lines and waves: Define functions representing your desired line/wave shapes. Generate x, y coordinates along the curves and apply extrusion or offsetting techniques.
You can try the following example code:
% Define grid parameters
x = [0:0.1:2];
y = [0:0.1:3];
z_height = 0.5; % Height of extrusion
% Generate grid and coordinates
[xq, yq] = meshgrid(x,y);
coords = [xq(:) yq(:) ones(numel(xq),1)*z_height]; % Add z-coordinate
% Generate mesh
DT = delaunayTriangulation(coords);
% Plot and potentially save as STL
hold on;
Tplot = triplot(DT,xq,yq);
hold off;
% Save as STL with trimesh library (uncomment if installed)
% TR = trimesh(DT, coords(:,1), coords(:,2), coords(:,3));
% stlwrite(TR,'extrudedGrid.stl');
Here are some links that could help:

Community Treasure Hunt

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

Start Hunting!

Translated by