Home > bioelectromagnetism > elec_2d_3d.m

elec_2d_3d

PURPOSE ^

elec_2d_3d - Project 2D planar Cartesian coordinates into 3D elliptical shape

SYNOPSIS ^

function [Xe,Ye,Ze] = elec_2d_3d(X,Y,Xrad,Yrad,Zrad)

DESCRIPTION ^

 elec_2d_3d - Project 2D planar Cartesian coordinates into 3D elliptical shape

 Useage: [Xe,Ye,Ze] = elec_2d_3d(X,Y,Xrad,Yrad,Zrad)

   Project 2D planar Cartesian coordinates into 3D elliptical shape,
   using gnomonic projection, which draws a line from points on a plane 
   tangential to north pole, to a point halfway between equator and south pole, 
   where the intersection with the ellipse is the position of the electrode.

   Given:      Set of 2D Cartesian coordinates on a plane (X,Y)
                3 radii of ellipsoid (Xrad,Yrad,Zrad)

   See also elec_3d_2d.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Xe,Ye,Ze] = elec_2d_3d(X,Y,Xrad,Yrad,Zrad)
0002 
0003 % elec_2d_3d - Project 2D planar Cartesian coordinates into 3D elliptical shape
0004 %
0005 % Useage: [Xe,Ye,Ze] = elec_2d_3d(X,Y,Xrad,Yrad,Zrad)
0006 %
0007 %   Project 2D planar Cartesian coordinates into 3D elliptical shape,
0008 %   using gnomonic projection, which draws a line from points on a plane
0009 %   tangential to north pole, to a point halfway between equator and south pole,
0010 %   where the intersection with the ellipse is the position of the electrode.
0011 %
0012 %   Given:      Set of 2D Cartesian coordinates on a plane (X,Y)
0013 %                3 radii of ellipsoid (Xrad,Yrad,Zrad)
0014 %
0015 %   See also elec_3d_2d.m
0016 %
0017 
0018 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0019 
0020 % Licence:  GNU GPL, no implied or express warranties
0021 % History:  10/1999, Chris Harvey
0022 %           07/2001, Darren.Weber_at_radiology.ucsf.edu
0023 %                    - using matrix algebra rather than indexed looping
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 %
0028 % The size of X and Y should be the same.
0029 % The size of Xe,Ye,Ze will be set to the same.
0030 %
0031 Xe = X;
0032 Ye = Y;
0033 Ze = Y;
0034 
0035 B = -1/2;
0036 C = -3/4;
0037 
0038 for i = 1:length(X)
0039 
0040     A = (X(i)/Xrad)^2 + (Y(i)/Yrad)^2 + 1/4;
0041 
0042     t1 = (-B + sqrt(B^2 - 4*A*C)) / (2*A);
0043 
0044     t2 = (-B - sqrt(B^2 - 4*A*C)) / (2*A);
0045 
0046     t = max(t1,t2);
0047 
0048     Xe(i) = X(i)*t;
0049     Ye(i) = Y(i)*t;
0050     Ze(i) = (-Zrad/2)*(1-t);
0051 end
0052

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