line intersection function in lua