Function for calculating distance between star systems