distance calculations for q on lines