Converting polar coordinates to X,Y,Z for 3d plots
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Polar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!