How to find segments intersection?

Maybe this topic will be useful for you: