用xyz点计算高斯曲率

时间:2018-05-03 10:08:33

标签: matlab grid mesh gaussian point-clouds

我将点组织成三个阵列 - XYZ。我想计算这些点的高斯曲率。

我发现a code执行此操作(如下),但似乎需要一个点网格。我知道我可以[x,y] = meshgrid(X,Y)获取两个输入,但我怎样才能获得z

function gc = gcurvature(x,y,z)

[xu,xv]     =   gradient(x);
[xuu,xuv]   =   gradient(xu);
[xvu,xvv]   =   gradient(xv);

[yu,yv]     =   gradient(y);
[yuu,yuv]   =   gradient(yu);
[yvu,yvv]   =   gradient(yv);

[zu,zv]     =   gradient(z);
[zuu,zuv]   =   gradient(zu);
[zvu,zvv]   =   gradient(zv);

for i=1:(size(z,1))
    for j=1:(size(z,2))
        Xu          =   [xu(i,j) yu(i,j) zu(i,j)];
        Xv          =   [xv(i,j) yv(i,j) zv(i,j)];
        Xuu         =   [xuu(i,j) yuu(i,j) zuu(i,j)];
        Xuv         =   [xuv(i,j) yuv(i,j) zuv(i,j)];
        Xvv         =   [xvv(i,j) yvv(i,j) zvv(i,j)];
        E           =   dot(Xu,Xu);
        F           =   dot(Xu,Xv);
        G           =   dot(Xv,Xv);
        m           =   cross(Xu,Xv);
        n           =   m/sqrt(sum(m.*m));
        L           =   dot(Xuu,n);
        M           =   dot(Xuv,n);
        N           =   dot(Xvv,n);
        gc(i,j)      =   ((L*N)-M^2)/((E*G)-F^2);
    end
end

1 个答案:

答案 0 :(得分:1)

如果我正确理解您的问题,您应该使用meshgridwhich has 3 outputs的另一个“重载”(即语法):

[x,y,z] = meshgrid(X,Y,Z);