![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298068/image.png)
Drawing a spiraling half circle
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Örs Istok
el 22 de Mayo de 2020
Comentada: Örs Istok
el 22 de Mayo de 2020
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298098/image.jpeg)
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.
0 comentarios
Respuesta aceptada
darova
el 22 de Mayo de 2020
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298068/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!