Code to transform cartesian to polar coordinate