How to do the Gauss Mapping in Matlab?

3 views (last 30 days)
Zara
Zara on 12 Jun 2013
Answered: Roberto Dyke on 3 May 2021
Hi all,
As you may know, the Gauss map (named after Carl F. Gauss) maps a surface in Euclidean space R3 to the unit sphere S2. I have a 3D surface with normals of each vertex. I want to map each normal on a unit Gauss sphere. Is there any function in Matlab for that or any reference with exact formulations that I can use?
Thanks in advance for your answers.

Answers (1)

Roberto Dyke
Roberto Dyke on 3 May 2021
Dear Zara,
Presumably this answer will not help you now, but for reference: Good news, if you already have the vertex normals for a surface, then you have your mapping to the Gauss unit sphere! Given a unit sphere S centred at (0,0,0), at point v(i) the vertex normal n(i) is a unit vector (i.e., norm(n(i))) that specifies a point on S that corresponds to the Gauss map at v(i).
There is a function built into MATLAB for computing the vertex normal. Below, I have provided some equivalent code, along with the rendering technique used by Rabinovich et al. (2018) see Fig. 15.
Roberto
% load mesh
M = struct('VERT',[X,Y,Z],'TRIV',F,'n',size(X,1),'m',size(F,1));
% (X,Y,Z) are n-by-1 vectors for the vertex position
% F is an m-by-3 matrix of 1-based face indicies
% compute face normals
A = M.VERT(M.TRIV(:,1),:);
B = M.VERT(M.TRIV(:,2),:);
C = M.VERT(M.TRIV(:,3),:);
NF = cross(B-A,C-A);
NF = NF ./ vecnorm(NF,2,2);
% compute vertex normals (i.e. Gauss map)
A = sparse(M.TRIV,repmat(1:M.m,1,3),true,M.n,M.m); % vertex-face adjacency matrix
NV = A*NF;
NV = NV ./ vecnorm(NV,2,2); % unit vector
% show result
figure;
% render vertex normals on mesh
subplot(1,2,1);
trisurf(M.TRIV,M.VERT(:,1),M.VERT(:,2),M.VERT(:,3),'FaceColor',[0.25,0.75,0.25]);
hold on;
quiver3(M.VERT(:,1),M.VERT(:,2),M.VERT(:,3),NV(:,1),NV(:,2),NV(:,3));
hold off;
axis equal off;
title('Original mesh w/ vertex normals');
% render Gauss map
scale = 0.95; % (<=1) reduce the size of the sphere, this is useful for smaller meshes
[X,Y,Z] = sphere;
subplot(1,2,2);
surf(X*scale,Y*scale,Z*scale,'FaceColor',[0.8,0.8,0.8],'EdgeAlpha',0); % render sphere
hold on;
trisurf(M.TRIV,NV(:,1),NV(:,2),NV(:,3),'FaceAlpha',0); % render wireframe
hold off;
axis equal off;
title('Gauss map');
  1. Rabinovich, M. & Hoffmann, T. & Sorkine-Hornung, O. 2018. Discrete Geodesic Nets for Modeling Developable Surfaces. ACM TOG, 37(2). pdf

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!