added methods to convert between Cartesian and spherical coordinates