line intersection algorithm