Draw a 3D model having x,y and z coordinates
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello everyone i would like to know if you can help me with this question. I have an (6000x3) array, where the columns represents x,y and z coordinates of a point that when u link all of the points , they form a cylinder.
Is posible to create the model with those coordinates?
댓글 수: 3
채택된 답변
KSSV
2020년 6월 6일
Your coordinates given are not forming a full cylinder. If you join them, you will not get a perfect cylinder as expected. As you said the points form a cyinder; I used the points to get radius and height of the cylinder, from this cylinder has been plotted.
data = xlsread("coordinates.xlsx") ;
x = data(:,1) ;
y = data(:,2) ;
z = data(:,3) ;
% Get radius of the Cylinder
Radius = mean(sqrt(x.^2+y.^2)) ;
% Center of cylinder
C = [0. 0.] ;
% Get height of the cylinder
Height = max(z) ;
% form cylinder
theta = 360. ; % Angle of the Cylinder
%
NH = 50 ; % Number of Elements on the Height
NT = 50 ; % Number of Angular Dicretisation
% Discretizing the Height and Angle of the cylinder
nH = linspace(0,Height,NH) ;
nT = linspace(0,theta,NT)*pi/180 ;
[H T] = meshgrid(nH,nT) ;
% Convert grid to cylindrical coordintes
X = Radius*cos(T);
Y = Radius*sin(T);
Z = H ;
surf(X,Y,Z)
hold on
plot3(x,y,z,'.k')
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!