colliding galaxies

Line of sight

How do you find the distance to objects quadrillions of km away?