I am programming an application that renders lines in 2d space. Each line has a direction, the direction = the angle between the 1st and last vertex on the line. I am attempting to determine the direction of 2 separate lines(each contain many 2d vertices) and re-orientate(reverse) them if they don't face the direction I require.
Criteria:
- If those 2 lines both face towards the intersection point then I need to reverse one of them so they sit 'head-to-tail'.
- If neither face the intersection point then I need to reverse one of them so they sit 'head-to-tail'.
- If one faces the intersection point and the other does not then I do nothing, they already are 'head-to-tail'.
Do you know of a methodology(mathematical function, algorithm or other) that would allow me to determine whether 2 lines meet 'head-on', 'tail-on' or 'head-to-tail'?
I think it also becomes especially difficult when the 2 lines do not physically intersect. But in this case I still need to determine their directions and ensure that IF they did intersect, that it would be a 'head-to-tail' intersection.