⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elec_cart2sph.m

📁 Matlab下的EEG处理程序库
💻 M
字号:
function [theta,phi,r] = elec_cart2sph(x,y,z,xo,yo,zo)

% ELEC_CART2SPH - Convert Cartesian (X,Y,Z) to spherical (theta,phi,r)
%
% Useage:   [theta,phi,r] = elec_cart2sph(X,Y,Z,xo,yo,zo)
%
% Result:   (theta,phi,r) are double floating point (Nx1);
%           r is radius,
%           theta is counterclockwise rotation from +x in x-y plane (azimuth),
%           phi is elevation with respect to Cz-axis,
%           theta & phi in radians,
%
%           +ve x-axis from origin through T4 (right ear)
%           +ve y-axis from origin through Nasion (at theta = +90degrees)
%           
% Note:     Conversion from Cartesian to spherical coordinates, with
%           origin or centroid (xo,yo,zo) is:
%           theta = atan( (y-yo) ./ (x-xo) );
%           phi = atan( sqrt( (x-xo).^2 + (y-yo).^2 ) ./ (z-zo) );
%           r = sqrt( (x-xo).^2 + (y-yo).^2 + (z-zo).^2);
%

% $Revision: 1.2 $ $Date: 2003/03/02 03:20:44 $

% Licence:  GNU GPL, no implied or express warranties
% History:  07/2001, Darren.Weber@flinders.edu.au
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~exist('xo', 'var') xo = 0; end
if ~exist('yo', 'var') yo = 0; end
if ~exist('zo', 'var') zo = 0; end

theta = atan( (y-yo) ./ (x-xo) );
phi = atan( sqrt( (x-xo).^2 + (y-yo).^2 ) ./ (z-zo) );
r = sqrt( (x-xo).^2 + (y-yo).^2 + (z-zo).^2 );

return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -