How to segment 3D point data
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a set of data points (xyz) that describes an upside down cone shape (One cone has something around 200.000 points.) I know the center point and shifted the origin of the coordiante system to this point.
Now i would like to slice the cone in pieces, similar to a cake. After that i would like to do some calculations for each silce (e.g.mean of all points in this slice)
I got so far:
- Import data
- shift origin to center of cone
- transform to cylindrical polar coordinates (theta rho z)
- sort the matrix according to the azimut angle theta
But now im stuck, how should I segment it, e.g. every slice should have an angle of 20 degree (0.3149 rad) or a different approach-> slice the cone in X even segments.
Since my data files are very big .csv files, im not sure if i can upload them here.
English is not my native language, i hope you can understand what im trying to say.
Here is my code: I'm sure there are some comsetical no no's in it, im by far nor Matlab expert, but learning constantly and try to improve myself, so please be gentle;-)
TEST
Importdir = dir('*.csv');
for i = 1:numel(Importdir);
M = Importdir(i).name;
M = csvread(M);
MID{i} = M(:,1);
Mx{i} = M(:,2);
My{i} = M(:,3);
Mz{i} = M(:,4);
end
for a = 1:numel(Importdir);
% Find position of cone center ID 1005
PosOrigin{a} = find(MID{a}==1005);
% Get value according to ID 1005 for x y z
x_center{a} = Mx{a}(PosOrigin{a},1);
y_center{a} = My{a}(PosOrigin{a},1);
z_center{a} = Mz{a}(PosOrigin{a},1);
% Make matrix with center values
center{a} = [x_center{a},y_center{a}, z_center{a}];
% Make Matrix of coordinates for cone
Mxyz{a} = [Mx{a}, My{a}, Mz{a}];
% Shift Cone to new origin
s{a} = Mxyz{a} - center{a};
end
for j = 1:numel(Importdir);
% make matrix to transformation in zylindrical coordinates
v = cell2mat(s(j));
% Transform catesian into cylindrical coordinates
[theta,rho,z] = cart2pol(v(:,1),v(:,2),v(:,3));
% Create Matrix and sort it in respect of theta (angle on xy plane)
l = [theta rho z];
lsort = sortrows(l,1);
%search = lsort(:,1);
% Find Angle to first Interval e.g. 0 to 20 degrees?
end
Thank You!
2 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!