1

我正在使用 surfnorm matlab 函数来计算表面法线。当我使用它作为:surfnorm(pcloud(:,:,1),pcloud(:,:,2),pcloud(:,:,3));表面法线的图形出现但法线值没有保存。所以我使用 :[Nx,Ny,Nz]=surfnorm(pcloud(:,:,1),pcloud(:,:,2),pcloud(:,:,3));但没有将正常值保存在 [Nx,Ny,Nz] 中,但不显示正常数字。那么如何两者兼得呢?

4

1 回答 1

1

根据文档,您要同时执行的两个操作似乎是互斥的:

 [Nx,Ny,Nz] = SURFNORM(X,Y,Z) returns the components of the 3-D 
 surface normal for the surface with components (X,Y,Z).  The 
 normal is normalized to length 1.

 [Nx,Ny,Nz] = SURFNORM(Z) returns the surface normal components
 for the surface Z.

 Without lefthand arguments, SURFNORM(X,Y,Z) or SURFNORM(Z) 
 plots the surface with the normals emanating from it.

 SURFNORM(AX,...) plots into AX instead of GCA.

但是,一旦创建,您就可以从表面法线图中检索法线矢量数据,如下所示:

h=figure;
surfnorm(pcloud(:,:,1),pcloud(:,:,2),pcloud(:,:,3));
axesObjs = get(h, 'Children');
dataObjs = get(axesObjs, 'Children'); 
[Nx,Ny,Nz] = deal(get(dataObjs(1), 'XData').', get(dataObjs(1), 'YData').', get(dataObjs(1), 'ZData').');

这似乎令人费解,但如果它是计算费用,您正在寻求避免这可能是最好的方法。

编辑:

(1) 您可以h=figure用调用来替换,figure然后是h=gcf

(2) 我对Nx, Ny, Nz向量的解释是包含由 绘制的向量的位置和方向的坐标(不一定是标准化的),surfnorm以及NaN附加值,所以如果你打印出来,[Nx,Ny,Nz]你应该会看到如下内容:

         0         0   -1.0000   <-- position of origin
         0         0   -1.0000   <-- direction of vector
       NaN       NaN       NaN   <-- nonsense
   -0.5878         0   -0.8090
   -0.7036   -0.0344   -0.9684
       NaN       NaN       NaN
   -0.9511         0   -0.3090
   -1.1341   -0.0543   -0.3685
       NaN       NaN       NaN
   -0.9511         0    0.3090
   -1.1341   -0.0543    0.3685
       NaN       NaN       NaN
    ....
于 2013-07-25T08:11:45.570 回答