To change the lines, hover over the endpoints and drag.
I got the algorithm from here: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect