Home > bioelectromagnetism > sphere_bounded_script.m

sphere_bounded_script

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 sphere = sphere_tri('ico',4,4);
0003 
0004 Xbound = 2;
0005 Ybound = 2;
0006 Zbound = 2;
0007 
0008 for i = 1:size(sphere.vertices,1),
0009   
0010   x = sphere.vertices(i,1);
0011   y = sphere.vertices(i,2);
0012   z = sphere.vertices(i,3);
0013   
0014   if x > Xbound, delete_index(end) = i; end
0015   if y > Ybound, delete_index(end) = i; end
0016   if z > Zbound, delete_index(end) = i; end
0017   
0018   % at this point you know if it lies outside
0019   % a bounding box, so try to find the distance
0020   % of this point from the bounding box and
0021   % determine whether it is less than the
0022   % length of a triangle edge.  If it is, then
0023   % maybe don't delete this vertex, just place
0024   % it on the edge of the box.  This is the
0025   % tricky bit, as what you might try to do
0026   % is maintain the integrity of the
0027   % triangulation at the bounding box edges.
0028   
0029   vertex2boxDistance = 0; % you need to calc this
0030   vertexEdgeDistance = 0; % you need to calc this
0031   
0032   if vertex2boxDistance < vertexEdgeDistance,
0033     % don't delete the vertex, just move it
0034     % consider using dsearchn function for this
0035   end
0036 end
0037

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003