2014-04-01 7 views
0

나는 3D 점 구름을 가지고 있으며, 포인트 클라우드에서 각 점의 평균 곡률을 MATLAB 코드를 사용하여 계산하려고합니다. 나는 함수 코드 아래에서 발견 :포인트 클라우드의 각 포인트에서 평균 곡률 및/또는 기타 유형 곡률을 계산하려면 어떻게해야합니까?

function [gm samc] = mcurvature_vec(x,y,z) 
% Description: The function calculates mean curvature and 
% Surface Avg Mean Curvature (SAMC) of a surface formed by x, y & z. 
% The input are the coordinate matrices x, y & z. The 
% matrices can be formed using meshgrid or similar functions. 
% This code is a vectorized form of original code (mcurvature) posted 
% on Matlab File Exchange. 

% The mean curvature is calculated according to the formula: 

% If x:U->R^3 is a regular patch, then the mean curvature is given by 
%  
%   H = (eG-2fF+gE)/(2(EG-F^2)), 
% 
% where E, F, and G are coefficients of the first fundamental form and 
% e, f, and g are coefficients of the second fundamental form 

% Reference: Gray, A. "The Gaussian and Mean Curvatures." §16.5 in 
% Modern Differential Geometry of Curves and Surfaces with Mathematica, 
% 2nd ed. Boca Raton, FL: CRC Press, pp. 373-380, 1997 (p. 377). 

% Inspired by: 
% Title: Mean Curvature 
% Author: Ahmed Elnaggar 
% Summary: Calculate the Mean curvature of a given surface (x,y,z). 

gm = zeros(size(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); 

Xu(:,:,1) = xu; 
Xu(:,:,2) = yu; 
Xu(:,:,3) = zu; 

Xv(:,:,1) = xv; 
Xv(:,:,2) = yv; 
Xv(:,:,3) = zv; 

Xuu(:,:,1) = xuu; 
Xuu(:,:,2) = yuu; 
Xuu(:,:,3) = zuu; 

Xuv(:,:,1) = xuv; 
Xuv(:,:,2) = yuv; 
Xuv(:,:,3) = zuv; 

Xvv(:,:,1) = xvv; 
Xvv(:,:,2) = yvv; 
Xvv(:,:,3) = zvv; 

E = dot(Xu,Xu,3); 
F   = dot(Xu,Xv,3); 
G   = dot(Xv,Xv,3); 
m   = cross(Xu,Xv,3); 
temp(:,:,1) = sqrt(sum(m.*m,3)); 
temp(:,:,2) = temp(:,:,1); 
temp(:,:,3) = temp(:,:,1); 
n   = m./temp; 
L   = dot(Xuu,n,3); 
M   = dot(Xuv,n,3); 
N   = dot(Xvv,n,3); 
gm   = ((E.*N)+(G.*L)-(2.*F.*M))./(2.*(E.*G - F.^2)); 

dim = size(z); 
samc = 1/ (dim(1) * dim(2)) * sum (gm(:).^2); 

하지만 기본적인 문제가있다. 처음 내 포인트는 포인트 구름 그리고 그들은 예를 들어 단지 X, Y 및 Z를을 가지고 :

32512035.2100000 5401399.57000000 346.880000000000 
32512044.0300000 5401399.54000000 346.850000000000 
32512046.8900000 5401399.55000000 346.780000000000 
32512049.7800000 5401399.53000000 346.860000000000 
32512052.6900000 5401399.53000000 346.700000000000 
32512054.0300000 5401399.53000000 346.780000000000 
32512055.6900000 5401399.57000000 346.810000000000 
32512063.1200000 5401399.54000000 347.800000000000 
32512074.2300000 5401399.55000000 346.440000000000 
32512093.1200000 5401399.54000000 346.660000000000 

을이 기능에 내가 오류가 아래의 사항 :의 크기와 관련이

Error in ==> mcurvature_vec at 28 
[xu,xv]  = gradient(x); 

X, Y 및 Z가 포함되어 있습니다. 내 데이터는 X, Y 및 Z 만 포함하는 점 구름이므로 각 점의 곡률을 계산하는 방법은 무엇입니까?

답변

0

같은 길이의 변수가 3이라면 함수를 호출하여 mcurvature_vec의 동작을 확인하십시오. 그것은 xy z를 기대하는 것 같다 x = rand (1, 100); 예 : ...