Calculate cosmological distances