- pc.Location are all [x,y,z] coordinates.
- idx is a logical vector identifying points in pc.Location that are in the bin
- section are the [x,y,z] coordinates within the bin.
Dividing the point cloud in 10x10 ways
8 次查看(过去 30 天)
显示 更早的评论
Hello, my problem is that I am working on a 3-dimensional point cloud like in the title and I want to split it into 10x10 pieces over x and y. As I am new to Matlab, I didn't know how to do this for now.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/559613/image.png)
0 个评论
回答(2 个)
Adam Danz
2021-3-29
编辑:Adam Danz
2021-4-1
Load built-in pointcloud data and look at the pointcloud object pc
load('xyzPoints');
pc = pointCloud(xyzPoints)
X/Y/ZLimits are the range of x,y,z points. Create a 10x10 grid within the x and y ranges. The bounds are defined in xyBounds (nx2).
[x,y] = meshgrid(linspace(pc.XLimits(1), pc.XLimits(2), 10), ...
linspace(pc.YLimits(1), pc.YLimits(2), 10));
xyBounds = [x(:),y(:)]
Use indexing to access a particular section of points.
Get all points within the bin #n
n = 50; % 50th bin xyBounds(n,:)
xIdx = pc.Location(:,1) >= xyBounds(n,1) & pc.Location(:,1) < xyBounds(n+1,1);
yIdx = pc.Location(:,2) >= xyBounds(n+1,2) & pc.Location(:,2) < xyBounds(n,2);
idx = xIdx & yIdx;
section = pc.Location(idx,:)
Some bins will not have any points and will return a 0x3 empty matrix.
darova
2021-3-24
see this example
clc,clear
x = rand(10,10,10);
y = rand(10,10,10);
z = rand(10,10,10);
ix = round(5*x);
iy = round(5*y);
plot3(x(:),y(:),z(:),'.b');
hold on
h = plot3(0,0,0,'or');
hold off
view(15,60)
for i = 1:5
for j = 1:5
ind = (i==ix) & (j==iy);
set(h,'xdata',x(ind))
set(h,'ydata',y(ind))
set(h,'zdata',z(ind))
pause(0.2)
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/561223/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/561228/image.png)
4 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!