Function distanceToLine