Home > atmlab > gridcreation > uniformsphere > SubdivideSphericalMesh.m

SubdivideSphericalMesh

PURPOSE ^

Subdivide triangular mesh representing the surface of the unit sphere

SYNOPSIS ^

function TR=SubdivideSphericalMesh(TR,k)

DESCRIPTION ^

 Subdivide triangular mesh representing the surface of the unit sphere
 k times using triangular quadrisection (see function TriQuad for more 
 info). The newly inserted vertices are re-projected onto the unit sphere
 after every iteration.

 INPUT ARGUMENTS:
   - TR   : input mesh. TR can must be specified as a TriRep object.
   - k    : desired number of subdivisions. k=0 is default.

 OUTPUT:
   - TR  : subdivided mesh. Same format as input.

 AUTHOR: Anton Semechko (a.semechko@gmail.com)
 DATE: June.2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

SubdivideSphericalMesh.m

SOURCE CODE ^

0001 function TR=SubdivideSphericalMesh(TR,k)
0002 % Subdivide triangular mesh representing the surface of the unit sphere
0003 % k times using triangular quadrisection (see function TriQuad for more
0004 % info). The newly inserted vertices are re-projected onto the unit sphere
0005 % after every iteration.
0006 %
0007 % INPUT ARGUMENTS:
0008 %   - TR   : input mesh. TR can must be specified as a TriRep object.
0009 %   - k    : desired number of subdivisions. k=0 is default.
0010 %
0011 % OUTPUT:
0012 %   - TR  : subdivided mesh. Same format as input.
0013 %
0014 % AUTHOR: Anton Semechko (a.semechko@gmail.com)
0015 % DATE: June.2012
0016 %
0017 
0018 if nargin<2 || isempty(k), k=0; end
0019 
0020 if k==0, return; end
0021 for i=1:k
0022     
0023     % Subdivide the mesh
0024     TR=TriQuad(TR);
0025     
0026     % Project the points onto the surface of the unit sphere
0027     x=TR.X;
0028     x_L2=sqrt(sum(x.^2,2));
0029     x=bsxfun(@rdivide,x,x_L2);
0030     TR=TriRep(TR.Triangulation,x);
0031     
0032 end
0033

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005