Changed solveForX to not attempt to divide by zero for 0 or undefined slopes