How do I export a plot comprising of multiple functions to .stl?

조회 수: 3 (최근 30일)
Aayush Chadha
Aayush Chadha 2020년 8월 20일
답변: Aayush Chadha 2020년 8월 22일
I have a plot created using multiple parametric functions that define an archimedean spiral. I want to export the plotted figure to stl or convert it into a mesh that resembles the plotted shape, however, am unable to do so. I have tried using triangulation and mesh grid but to no avail. The plot I want to export is shown above.
This plot was generated using:
% Spiral edges
x = (inner_radius + spiral_growth_rate.*angles).*cos(angles);
y = (inner_radius + spiral_growth_rate.*angles).*sin(angles);
syms theta
diff_x = diff((inner_radius +spiral_growth_rate*theta)*cos(theta));
diff_y = diff((inner_radius +spiral_growth_rate*theta)*sin(theta));
N_x = (-diff_y)/sqrt(diff_x^2 + diff_y^2);
N_y = (diff_x)/sqrt(diff_x^2 + diff_y^2);
shift_x = vpa(subs(N_x, theta, angles));
shift_y = vpa(subs(N_y, theta, angles));
outer_x_coords = x+shift_x.*thickness/2;
outer_y_coords = y+shift_y.*thickness/2;
inner_x_coords = x-shift_x.*thickness/2;
inner_y_coords = y-shift_y.*thickness/2;
% Joining curves
s = linspace(-1, 1);
inner_j_x = x(1) + s .* shift_x(1)*thickness/2;
inner_j_y = y(1) + s .* shift_y(1)*thickness/2;
outer_j_x = x(end) + s .* shift_x(end).*thickness/2;
outer_j_y = y(end) + s .* shift_y(end).*thickness/2;
x_coords = double([inner_x_coords, outer_x_coords, inner_j_x, outer_j_x]);
y_coords = double([inner_y_coords, outer_y_coords, inner_j_y, outer_j_y]);
% [X,Y] = meshgrid(x_coords, y_coords);
%
% T = delaunay(X,Y);
% trimesh(T,x,y);
figure
hold on
plot(outer_x_coords, outer_y_coords);
plot(inner_x_coords, inner_y_coords);
plot(inner_j_x, inner_j_y);
plot(outer_j_x, outer_j_y);
hold off

채택된 답변

Aayush Chadha
Aayush Chadha 2020년 8월 22일
In case someone ever encounters a similar problem. I ended up doing this by generating the points in Python and then using pygmsh to generate the mesh. I wrote this mesh to STL, opened and saved it using Meshlab (I do not know why the mesh couldn't be read otherwise by customAntennaStl) before I was able to finally use it.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by