Curve (Spiral) Based on Changing Radius
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Paul Huter
am 18 Jul. 2015
Kommentiert: Star Strider
am 18 Jul. 2015
I see plenty of solutions for plotting spirals/curves based on an angle, but is there a way to plot a curve based on a changing radius? For example, the distance between the point that is "tracing" and the point it is tracing around starts at 20 meters, but decreases to 0 meters over 1 second then increases back to 20 meters over 1 second. The point is rotating at pi/2 rad/s, so it should complete 180-deg in the 2 seconds. I have no idea what this would look like, which is why I am trying to plot it.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 18 Jul. 2015
This seems to me to work, although it’s difficult to appreciate the radius effect with only a half-turn of the helix:
t = linspace(0, 2, 500);
wt = (t/2)*pi/2;
radius = cos(2*pi*t/max(t)) * 20;
c = @(r,th) [r.*cos(th); r.*sin(th)];
curve = c(radius,wt)+1;
figure(1)
plot3(curve(1,:), curve(2,:), t)
grid on
xlabel('x')
ylabel('y')
zlabel('t')
figure(2)
plot(t, curve(1,:), t, curve(2,:), t,radius)
grid
title('Components Of ‘plot3’ Plot')
legend('x = cos', 'y = sin', 'radius', 'Location','N')
4 Kommentare
Star Strider
am 18 Jul. 2015
My error. You want ‘wt’ to go from 0 to pi, and ‘t’ goes from 0 to 2, so it should have been:
wt = (t/2)*pi;
radius = (0.5*cos(2*pi*t/max(t)) + 0.5) * 20;
For some reason, I was thinking pi/2.
The rest of the code works without modification.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!