The geometry of solar and lunar eclipses