The geometry of impossible figures