How to create a helix path in plot3?

3 visualizaciones (últimos 30 días)
adam adam
adam adam el 26 de Oct. de 2018
Respondida: Star Strider el 26 de Oct. de 2018
The code under creates a truncated pyramid with a contour path. I want to edit this into helix path. Is there anyone can help me. Thanks!!
L = 50 ; B = 50 ; H = -30 ;
theta = 45 ;
% Bottom rectangle
B = [0 0 0; L 0 0; L B 0; 0 B 0; 0 0 0] ;
mx = mean(B(1:4,1)) ; my = mean(B(1:4,2)) ;
h = 0:-3:H ;
figure
hold on
plot3(B(:,1),B(:,2),B(:,3),'r')
for i = 1:length(h)
C = [mx my h(i)] ;
x = h(i)/tand(theta) ;
s = L/2-x ;
% Top rectangele points
T = [mx-s my-s h(i); mx+s my-s h(i) ; mx+s my+s h(i) ; mx-s my+s h(i) ; mx-s my-s h(i)] ;
plot3(T(:,1),T(:,2),T(:,3),'b')
end

Respuestas (1)

Star Strider
Star Strider el 26 de Oct. de 2018
I am not certain what result you want.
Try this:
th = 0:pi/2:2*numel(h)*pi;
hv = linspace(0, H, numel(th));
x = cos(th+pi/4) .* hv * L/max(abs(hv));
y = sin(th+pi/4) .* hv * B/max(abs(hv));
figure
plot3(x, y, hv)
grid on

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by