用xyz点计算高斯曲率
Calculating gaussian curvature with xyz points
我将点组织成三个数组 - X
、Y
和 Z
。我想计算这些点的高斯曲率。
我发现 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
如果我正确理解你的问题,你应该使用 meshgrid
、which has 3 outputs:
的另一个 "overload"(即语法)
[x,y,z] = meshgrid(X,Y,Z);
我将点组织成三个数组 - X
、Y
和 Z
。我想计算这些点的高斯曲率。
我发现 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
如果我正确理解你的问题,你应该使用 meshgrid
、which has 3 outputs:
[x,y,z] = meshgrid(X,Y,Z);