Transform Cartesian coordinates to polar or cylindrical
[theta,rho]
= cart2pol(x,y)
[theta,rho,z]
= cart2pol(x,y,z)
The mapping from two-dimensional Cartesian coordinates to polar coordinates, and from three-dimensional Cartesian coordinates to cylindrical coordinates is