简体   繁体   English

在Matlab中绘制包含3d点云的球体

[英]Plot sphere containing a 3d point cloud in Matlab

I have a three-dimensional point cloud saved in a PLY file. 我有一个保存在PLY文件中的三维点云。

Taking a point (x, y, z) as the center of the sphere, I want to plot the whole point cloud, but with a sphere of radius R which contains several points of the point cloud, but not all the cloud. 以点(x,y,z)为球的中心,我想绘制整个点云,但是半径为R的球体包含点云的几个点,但不是所有的云。

The sphere shpould be quite transparent to let the points inside itself visible. 球体应该非常透明,以使其内部的点可见。

I have tried the following with no success: 我试过以下但没有成功:

% Read point cloud file
ptCloud = pcread('frame0000.ply');
% Show point cloud
pcshow(ptCloud);
hold on

% Sphere generation
[x, y, z] = sphere;
surf(x,y,z)
hold on 
% Sphere centered at (3, -2, 0)
surf(x+3,y-2,z) 

Doing this, I get a plot with a sphere centered at (3, -2, 0), but it takes ALL the pointcloud inside the sphere. 这样做,我得到一个带有以(3,-2,0)为中心的球体的图,但它占据了球体内的所有点云。 What's more, I cannot see the point cloud as the sphere is opaque. 更重要的是,我看不到点云,因为球体是不透明的。

How can I give a specific radius to the sphere so that it only takes the points within that radius R? 如何给球体指定一个特定的半径,使其仅取半径R内的点? And, how can I make the sphere transparent but not invisible, so that the points within the sphere are visible? 而且,如何使球体透明但不可见,以便球体内的点可见?

I appreciate all answers! 我感谢所有答案! 😊 😊

There are two things: 有两件事:

  1. Creating a sphere -- Using the Matlab function sphere , you could create a unit sphere. 创建球体 - 使用Matlab函数sphere ,可以创建单位球体。 If you want to shrink/enlarge, you could multiply the x, y, and zs' with a scalar. 如果要缩小/放大,可以将x,y和zs'与标量相乘。 Make sure you do that before shifting the origin. 确保在移动原点之前执行此操作。 After that, you could shift the origin. 在那之后,你可以改变原点。

  2. Plotting the sphere and manipulating the properties of the plot -- Here, you can change the properties of the figure to make it transparent. 绘制球体并绘制绘图的属性 - 在这里,您可以更改图形的属性以使其透明。 There are various options which could be found at Surface Properties . Surface Properties可以找到各种选项。

Example: 例:

[x, y, z] = sphere;
mesh(3*x+3,3*y-2,3*z, 'Marker', '.', 'EdgeColor', 'flat', 'FaceColor', 'none', 'LineStyle', ':')
hold on;
plot3(3, -2, 0, '+r', 'MarkerSize', 20)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM