Plotting two Spherical helix on top of each other with one being 90 deg shifted rotated about the z axis
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
William Black
el 5 de Ag. de 2021
Comentada: William Black
el 6 de Ag. de 2021
The code below plots a spherical helix.
What I want is another spherical helix plotted on top but rotated 90deg about the z axis (different colors are to be used for the second helix)
% Set the Order #
Order = 5;
% Set 3D attributes
t = 0:0.01:Order*pi;
% set x, y and z curves
%positive half
xp = sin(-t/Order).*cos(t);
yp = sin(t/Order).*sin(t);
zp = cos(t/Order);
%Negative Half
xn = sin(t/Order).*cos(t);
yn = sin(-t/Order).*sin(t);
zn = cos(t/Order);
% Set figure number
figure(Order);
% Plot all curves as defined
plot3(xp, yp, zp, xn, yn, zn);
% Label 3D axis
xlabel('X');
ylabel('Y');
zlabel('Z');
0 comentarios
Respuesta aceptada
Scott MacKenzie
el 5 de Ag. de 2021
Editada: Scott MacKenzie
el 6 de Ag. de 2021
For a before-and-after comparision, substitute the following for the plot3 line in your code. The z-axis rotation isn't particularly obvious, but look carefully and I think this is what you are after.
tiledlayout(1,2);
nexttile; % plot on left
% this is what the code in the question generates
plot3(xp, yp, zp, xn, yn, zn);
nexttile; % plot on right
% plot 1st curve as is
plot3(xp, yp, zp);
hold on;
% plot 2nd curve with 90 degrees rotation about z-axis
h = plot3(xn, yn, zn);
rotate(h, [0 0 1], 90);
or perhaps...
tiledlayout(1,2);
nexttile;
% this is what the code in the question generates
plot3(xp, yp, zp, xn, yn, zn);
nexttile;
% plot the two curves in separate colors with 2nd curve rotated
plot3(xp, yp, zp, 'b', xn, yn, zn, 'b');
hold on;
h = plot3(xp, yp, zp, 'm', xn, yn, zn, 'm');
rotate(h, [0 0 1], 90);
3 comentarios
Scott MacKenzie
el 6 de Ag. de 2021
@William Black, you're welcome. Glad to help.
BTW, does my answer actually create the graph you want? I was thinking after posting it, that perhaps you wanted the entire two-curve helix to be replicated with rotation added, and with a distinct color for each helix. I just added some additional code to that effect, just in case. Again, good luck.
Más respuestas (0)
Ver también
Categorías
Más información sobre Camera Views 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!