我正在使用surfnorm matlab函数来计算表面法线。当我将其用作:surfnorm(pcloud(:,:,1),pcloud(:,:,2),pcloud(:,:,3));
时,会出现曲面法线的图形,但不会保存正常值。所以我使用了[Nx,Ny,Nz]=surfnorm(pcloud(:,:,1),pcloud(:,:,2),pcloud(:,:,3));
但不是它在[Nx,Ny,Nz]中保存正常值而不是显示正常数字。那么如何制作两者?
答案 0 :(得分: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
....