点云生成 [英] Point Cloud Generation

查看:313
本文介绍了点云生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我具有3D几何形状,必须将其转换为点云.
  • 可以将所得的点云视为等效于从对象的激光扫描输出的点云.
  • 不需生成网格物体
  • 生成的点可以均匀分布,也可以随机分布-没关系
  • 可以以3-D数学公式的形式提供3-D形状
  • 必须使用MATLAB来完成

推荐答案

没有示例就很难回答,但听起来您只想执行

It's difficult to answer without an example but it sounds like you just want to perform a montecarlo simulation?

假设您的形状由函数f定义,并且您将X,Y限制存储在两个元素向量中,例如xlim = [-10 10],即此形状的所有可能x值都在x = -10和x = 10之间,那么我建议您使f返回某种错误代码(如果没有特定xy的值)一对.我将假定为NaN.因此,f(x,y)是您正在编写的函数,如果可以,则返回z,如果不能,则返回NaN

Lets say your shape is defined by the function f and that you have X, Y limits stored in two element vector e.g. xlim = [-10 10] i.e. all possible x values of this shape lie between x = -10 and x = 10 then I would suggest that you make f return some sort of error code if there is no value for a specific x-y pair. I'm going to assume that will be NaN. So f(x,y) is a function you are writing that either returns a z if it can or NaN if it can't

n= 10000;
counter  = 1;
shape = nan(n, 3)
while counter < n
   x = rand*diff(xlim) + mean(xlmin);
   y = rand*diff(ylim) + mean(ylim);
   z = f(x,y)
   if ~isnan(z)
      shape(counter, :) = [x, y, z];
      counter = counter + 1    
   end
end

因此,上面的代码将在整个形状中随机生成10000个(非唯一的,但很容易适应)点.

So the above code will generate 10000 (non unique, but that's easily adapted for) points randomly sample across your shape.

现在,键入此代码后,我意识到也许您的形状实际上并不那么大,也许您可​​以对其进行均匀采样而不是随机采样:

Now after typing this I realise that perhaps your shape is actually not all that big and maybe you can uniformly sample it rather than randomly:

for x = xlim(1):xstep:xlim(2)
   for y = ylim(1):ystep:ylim(2)
       shape(counter, :) = [x, y, f(x,y)];
   end
end 

或者如果您编写f进行矢量化(首选)

or if you write f to be vectorized (preferable)

shape = [(xlim(1):xstep:xlim(2))', (ylim(1):ystep:ylim(2))', f(xlim(1):xstep:xlim(2), ylim(1):ystep:ylim(2));

然后任意选择

shape(isnan(shape(:, 3), :) = []; %remove the points that fell outside the shape

这篇关于点云生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆