Azzera filtri
Azzera filtri

Converting polar coordinates to X,Y,Z for 3d plots

2 visualizzazioni (ultimi 30 giorni)
Alex
Alex il 12 Set 2017
Risposto: KL il 12 Set 2017
Hi all, I am rather new in matlab and I am trying to build some code that will help me draw three circle lines (with the same center). This is my first step in plotting measurements conducted in three measurement planes XY,YZ,and XZ that have to be displayed as a 3d plot.
Each of these three planes have associated a number and a degree. For simplification purposes we can assume that number being one. My first idea was to convert the polar coordinates I have (number,degree) to the equivalent X,Y,Z by the code below I wrote in matlab. Feel free to test it and help me find out why those three circles do not have the same center (0,0,0)
X1=turnPolarToX(1,1:360);
Y1=turnPolarToY(1,1:360);
Z1=ones(360);
X2=turnPolarToX(1,1:360);
Y2=ones(360);
Z2=turnPolarToY(1,1:360);
X3=ones(360);
Y3=turnPolarToX(1,1:360);
Z3=turnPolarToY(1,1:360);
plot3(X1,Y1,Z1)
hold on;
plot3(X2,Y2,Z2)
plot3(X3,Y3,Z3)
function d = degreeToRadian(degree)
d = 0.01745329252*degree;
end
function t=turnPolarToX(Amplitude,Coordinate)
t = Amplitude*cos(degreeToRadian(Coordinate))
end
function t=turnPolarToY(Amplitude,Coordinate)
t = Amplitude*sin(degreeToRadian(Coordinate))
end
Thanks a lot for your help. Regards Alex

Risposte (2)

Rik
Rik il 12 Set 2017
Is there a reason that you can't use the built-in pol2cart? If so, I'll have look at your actual code.

KL
KL il 12 Set 2017
Because you have ones(360) in all three cases. Change it to zeros(360) and all the circles will be oriented at the origin.

Categorie

Scopri di più su Polar Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by