I'm facing a problem to get the range segment when two segment lines are colliding. If they just cross each other in one point, I'm using the algorithm provided by Gavin in this answer from the book Tricks of the Windows Game Programming Gurus (2nd Edition), but this code doesn't works when the segmets overlaps in two points, like the image bellow shows.
How can I get the red segment when the lines are colliding in this situation?