Drawing a spiraling half circle
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
