Drawing a spiraling half circle

2 次查看(过去 30 天)
Dear all,
I hit a wall while trying to solve this problem I have. I am trying to draw a spiraling half-circle (as seen in figure below, B) with n turns and extracting the x,y coordinates for the lines.
For now, I managed to draw something like (A), but I need to get the B. I atempted to do B myself, but I can only solve it by having the vertical lines slightly angled. Then I got an ideea to draw the geometry using something like iamfreehand function. Found a good code here(https://www.mathworks.com/matlabcentral/answers/320227-how-can-i-draw-with-mouse-as-we-do-in-paint) that does some of the job for the straight lines, but then I need to also draw the arcs that have a descending radius each turn and also displace the x middle coordinate of the n-th turn.
This is my attempt to solve B, but my problem is that... say the starting position(x2,y2) for arc n = 2 is not the same as ending position(x1,y2) for arc n = 1;
I haven't included yet the vertical lines.
clear all, close all
s = 0.01;
cx = 0; %arc center coordinate for x-axis
cy = 0; %arc center coordinate for y-axis
N = 51; %number of points / arc
d = 0.15; %circle diameter
r = d/2; % radius
ncoil = 3; %number of arcs
length = 2*pi*r + 2*r; %total length of coil 1 in meters
length_arc = 2*pi*r;
a = length_arc/1000;
a1 = (a:a:a*ncoil)';
sin_alfa(:,1) = a1./r;
alfa = asin(sin_alfa);
for i = 1 : ncoil
for j = 1 : N
th1(:,i) = linspace(-pi/2, pi/2-alfa(i,1),N);
x_right(j,i) = ((r-10*a1(i,1)/2) .* cos(th1(j,i)) + cx + a1(i,1));
y_right(j,i) = ((r-10*a1(i,1)/2) .* sin(th1(j,i)) + cy);
end
end
for i = 1 : 1
figure(1)
plot(x_right, y_right)
hold on
daspect([1,1,1])
end
hold off
I know some of you have great ideeas to solve this, so please help me out. Any solution is wellcomed :)!
Thank you!
Ors.

采纳的回答

darova
darova 2020-5-22
Try polyxpoly. Here is a start
clc,clear
cla
[x,y] = pol2cart(-pi/2:.1:pi/2,1);
for i = 3:5
r = 5+i;
[xc,yc] = polyxpoly(r*x,r*y,[1 1]*(10-i),[-1 1]*10);
line(r*x,r*y)
line(xc,yc,'marker','.')
pause(0.5)
end
axis equal

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by