i need to find the intersection point of 2 line segments (lines are finite, i.e., they have end points).
e.g. segment 1 from x1,y1 to x2,y2 -- segment 2 from x3,y3 to x4,y4
you can assume m1 and m2 are the gradients of segment 1 and segment 2 respectively
similarly, c1 and c2 being the y-intercepts of segment 1 and segment 2 respectively
using 'y=mx+c' i can easily find the equations of both lines and then derive the intersection point from those equations and check if that point actually lies on both line segments (intersection point may not be between the end points).
my problem is when i calculate the gradients (m1 and m2) i do [y2-y1]/[x2-x1] there for if one of the lines is vertical then im gonna have problems. how can i deal with this?
another problem is that if the two segments intersect at a point which is also the same as one of the end points then i want to assume that they are not intersecting..
e.g. if segment 1 is from 2,3 to 3,7 and segment 2 is from 3,7 to 7,3 then i want to assume they dont intersect.