You can create a custom version of the line segment intersection here too. You can get rid of all the checks that return `undefined` because you know they intersect. The intersection simplifies to:

p + (p.y / (p.y - p1.y)) * (p1 - p)