📄 elec_sph2cart.m
字号:
function [X,Y,Z] = elec_sph2cart(theta,phi,r,angle)
% ELEC_SPH2CART - convert spherical to Cartesian coordinates
%
% Convert from spherical (theta,phi,r) to Cartesian rectangular (x,y,z)
% coordinates.
%
% Useage: [X,Y,Z] = elec_sph2cart(theta,phi,r,angle)
%
% theta is counterclockwise rotation from +x in x-y plane (azimuth),
% phi is elevation with respect to Cz-axis,
% r is radius,
% angle = 1=radians (default) or 0=degrees for theta & phi
%
% Result: (X,Y,Z) are double floating point
%
% Note: Conversion from spherical to Cartesian coordinates is:
%
% x = r .* sin(phi) .* cos(theta);
% y = r .* sin(phi) .* sin(theta);
% z = r .* cos(phi);
%
% +ve x-axis from origin through T4 (right ear)
% +ve y-axis from origin through Nasion (at theta = +90degrees)
%
% Results from this routine are not the same as those from
% the inbuilt sph2cart matlab function. Phi here is
% elevation with respect to z-axis. The matlab function
% sph2cart uses elevation with respect to xy plane.
%
% $Revision: 1.2 $ $Date: 2003/03/02 03:20:44 $
% Licence: GNU GPL, no express or implied warranties
% History: 07/2001, Darren.Weber@flinders.edu.au
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('angle','var') angle = 1; end
if isequal(angle,0),
% convert theta and phi to radians
theta = theta * (pi/180); phi = phi * (pi/180);
end
X = r .* sin(phi) .* cos(theta);
Y = r .* sin(phi) .* sin(theta);
Z = r .* cos(phi);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -