Changing from 2D plot to 3D plot and to STL file
3 views (last 30 days)
Show older comments
Hello everyone, I have these following codes: All of them creates a 2D plot, now I really want to create a 3D plot with Z: the thickness of plot XY. Then I want to convert it to STL file.
clc;
clear all;
close all;
% Input
R0 = 0.15;
a = 25*pi/180;
theta = 0:pi/1000:3*pi;
theta2 = theta + pi;
delta = pi/2;
%% Curl 1
R1 = R0*exp(a*(theta-delta));
X1 = R1.*cos(theta-delta);
Y1 = R1.*sin(theta-delta);
%% Curl 2
R2 = R0*exp(a*(theta-delta));
X2 = R2.*cos(theta);
Y2 = R2.*sin(theta);
%% Curl 3
R3 = R0*exp(a*(theta2-delta));
X3 = R1.*cos(theta2-delta);
Y3 = R1.*sin(theta2-delta);
%% Curl 4
R4 = R0*exp(a*(theta2 - delta));
X4 = R2.*cos(theta2);
Y4 = R2.*sin(theta2);
%% Extra plot (arc)
radius = R0*exp(a*(3*pi-pi/2));
a1 = pi/2;
b1 = pi;
h = 0;
k = 0;
t1 = linspace(a1,b1,3001);
X_arc1 = radius*cos(t1) + h;
Y_arc1 = radius*sin(t1) + k;
a2 = -pi/2;
b2 = 0;
t2 = linspace(a2,b2,3001);
X_arc2 = radius*cos(t2) + h;
Y_arc2 = radius*sin(t2) + k;
R5 = 0.05;
X5 = R5.*cos(theta);
Y5 = R5.*sin(theta);
%% Plot
figure(1);
plot(X1,Y1, 'k', 'LineWidth', 3); hold on
plot(X2,Y2, 'k', 'LineWidth', 3); hold on
P1 = plot(X_arc1, Y_arc1, 'k');
set(P1,'linewidth',3);
axis([h-radius-1 h+radius+1 k-radius-1 k+radius+1])
axis square; hold on;
plot(X3,Y3, 'k', 'LineWidth', 3);hold on
plot(X4,Y4, 'k', 'LineWidth', 3);hold on
plot(X5,Y5, 'k', 'LineWidth', 3); hold on
P2 = plot(X_arc2, Y_arc2, 'k');
set(P2,'linewidth',3);
axis('equal');
title('Two-arm equiangular spiral antenna', 'fontsize',14, 'fontweight','bold');
hold on
%% Filling with black color
patch([X1; flipud(X2)], [Y1; flipud(Y2)],'k');
patch([X3; flipud(X4)], [Y3; flipud(Y4)],'k');
X_arc1_bonus = horzcat(X_arc1, -4, -2.2, -2, -1, -0.3);
Y_arc1_bonus = horzcat(Y_arc1, 0.8, 2.2, 2.6, 3, 3.2);
fill(X_arc1_bonus, Y_arc1_bonus,'k');
X_arc2_bonus = horzcat(X_arc2, 4, 2.2, 2, 1, 0.3);
Y_arc2_bonus = horzcat(Y_arc2, -0.8, -2.2, -2.6, -3, -3.2);
fill(X_arc2_bonus, Y_arc2_bonus,'k');
0 Comments
Answers (0)
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!