Used std::atan2 to handle most of the work in get_distance.

std::atan2(y, x) computes std::atan(y, x) and handles the case where one of the values is equal to zero. The function get_distance was actually doing manually what std::atan2 is for.