function [r,theta,phi]=cart2pol(x,y,z)
% function [r,theta,phi]=cart2pol(x,y,z)
%
% transformation from cartesian coordinates to polar coordinates
% algorithms by Montenbruck/Pfleger: "Astronomy with the Personal Computer"
%
% 05.05.04 M.Penzkofer
rho = pi/180;
D2 = x*x+y*y;
r = sqrt(D2+z*z);
phi = atn2(y,x);
if (phi < 0)
phi = phi+360;
end
D = sqrt(D2);
theta = atn2(z,D);