Converting coordinates from Cartesian to polar