center_of_simps

PURPOSE ^

CENTER_OF_SIMPS: Calculates the Center of Mass of the Simplicies.

SYNOPSIS ^

function [center_simp]=center_of_simps(fwd_model, extraparam)

DESCRIPTION ^

 CENTER_OF_SIMPS: Calculates the Center of Mass of the Simplicies.

 Usage type #1
 [center_simp]=center_of_simps(fwd_model);
 Usage type #2
 [center_simp]=center_of_simps(simp,vtx);

 center_simp = The center of mass of simps 
               [Nelems x 3] (x y z co-ordinates)

 (C) 2005 David Stephenson. Licensed under GPL Version 2
 $Id: center_of_simps.html 2819 2011-09-07 16:43:11Z aadler $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [center_simp]=center_of_simps(fwd_model, extraparam)
0002 % CENTER_OF_SIMPS: Calculates the Center of Mass of the Simplicies.
0003 %
0004 % Usage type #1
0005 % [center_simp]=center_of_simps(fwd_model);
0006 % Usage type #2
0007 % [center_simp]=center_of_simps(simp,vtx);
0008 %
0009 % center_simp = The center of mass of simps
0010 %               [Nelems x 3] (x y z co-ordinates)
0011 %
0012 % (C) 2005 David Stephenson. Licensed under GPL Version 2
0013 % $Id: center_of_simps.html 2819 2011-09-07 16:43:11Z aadler $
0014 
0015 if nargin==1
0016     simp= fwd_model.elems;
0017     vtx = fwd_model.nodes;
0018 else
0019     simp= fwd_model;
0020     vtx= extraparam;
0021 end
0022 
0023     x_sum=vtx(simp(:,1),1)+vtx(simp(:,2),1)+vtx(simp(:,3),1)+vtx(simp(:,4),1);
0024     y_sum=vtx(simp(:,1),2)+vtx(simp(:,2),2)+vtx(simp(:,3),2)+vtx(simp(:,4),2);
0025     z_sum=vtx(simp(:,1),3)+vtx(simp(:,2),3)+vtx(simp(:,3),3)+vtx(simp(:,4),3);
0026     
0027     x_center=x_sum/4;
0028     y_center=y_sum/4;
0029     z_center=z_sum/4;
0030     
0031     center_simp(:,1)=x_center;
0032     center_simp(:,2)=y_center;
0033     center_simp(:,3)=z_center;
0034     
0035 
0036 
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 % This is part of the EIDORS suite.
0039 % Copyright (c) D.R Stephenson 2004
0040 % Copying permitted under terms of GNU GPL
0041 % See enclosed file gpl.html for details.
0042 % EIDORS 3D version XXX
0043 % MATLAB Version 6.5.0.180913a (R13)
0044 % MATLAB License Number: 1560
0045 % Operating System: Microsoft Windows XP Version 5.1 (Build 2600: Service Pack 1)
0046 % Java VM Version: Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005