File Exchange

## Gaussian Curvature

version 1.0.0.0 (427 Bytes) by Ahmed Elnaggar

### Ahmed Elnaggar (view profile)

Given a surface of point cloud data (x,y,z), the output is a matrix containing gaussian curvature.

Updated 15 Jun 2004

The input should be matrix containing points in (x,y,z). The output is the gaussian curvature at each point. The calculation is based on the first and second fundamental form. In order to calculate the k1 and k2, you need to use the first file 'mean curvature'.

Abdelrahman Shaath

### Abdelrahman Shaath (view profile)

Below is the corrected version
% First Derivatives
% Second Derivatives
% Initialize Gaussian and mean curvature
K = zeros(size(Z));
H = zeros(size(Z));
% Calculate both Gaussian and mean curvature
for i=1:size(Z,1)
for j=1:size(Z,2)
% assign vector values that we are going to work on
r_u = [Xu(i,j) Yu(i,j) Zu(i,j)];
r_v = [Xv(i,j) Yv(i,j) Zv(i,j)];
r_uu = [Xuu(i,j) Yuu(i,j) Zuu(i,j)];
r_uv = [Xuv(i,j) Yuv(i,j) Zuv(i,j)];
r_vv = [Xvv(i,j) Yvv(i,j) Zvv(i,j)];
% First fundamental Coeffecients of the surface (E,F,G)
E = dot(r_u, r_u);
F = dot(r_u, r_v);
G = dot(r_v, r_v);
% Calculate the unite normal vector (the perpendicular vector for
% both of these vectors)
m = cross(r_u,r_v,2);
n = m./sqrt(dot(m,m,2));
% Second fundamental Coeffecients of the surface (L,M,N)
L = dot(r_uu,n);
M = dot(r_uv,n);
N = dot(r_vv,n);
% Gaussian Curvature
K(i,j) = (L.*N - M.^2)./(E.*G - F.^2);
% Mean Curvature
H(i,j) = (E.*N + G.*L - 2.*F.*M)./(2*(E.*G - F.^2));
end
end

masyrezaei

### masyrezaei (view profile)

Hi Rakesh,
I am getting the Error in gradient (line 49)
[err,f,ndim,loc,rflag] = parse_inputs(f,varargin);

How did you overcome?
Give an example showing how to pass parameters to run.

great

abuzer

### abuzer (view profile)

There is an error occured while running the programme.

[err,f,ndim,loc,rflag] = parse_inputs(f,varargin);

rao yonghui

Sokrates

### Sokrates (view profile)

I cannot understand how can we estimate the curvature without knowing how the topology between these points is (triangle mesh, connectivity etc). Any help?

Thanks

Atul Kumar

### Atul Kumar (view profile)

I am not able to run the code on point cloud data. Does x,y,z means three coordinates of the data or a meshgrid??

S. D.

Poor loopy code...

Dr R P GUPTA

Excellent

lin van

what is z standing for

ali samer

its very good

Daniel Claxton

Thankyou for this code. I was just thinking of writing it myself and was pleased to see someone had already done it. As for Claude's comment, I don't think he is being fair or constructive. So, with that said, I have done a bit of optimization and vectorized your code. It seems to be running about 65 times faster... I'll post it soon

lala conde

Claude Gouédard

Matlab is teaching elementary school students
not to use loops !
From a teaching point of vue, again, I propose to modify your function in this way.

##### MATLAB Release Compatibility
Created with R12.1
Compatible with any release
##### Platform Compatibility
Windows macOS Linux