DesignerX 174 Report post Posted August 3, 2007 I have two 2D points (x1, y1) (x2, y2) and I have an infinite line . I want to find if the infinite line itersects the line rendered by the two given points (lets call it L). If the infinite line intesrect a part of L that is not between the given points I want to detect that). What is the simpliest (and efficient) way to achieve that ? thx alot. 0 Share this post Link to post Share on other sites
grhodes_at_work 1385 Report post Posted August 3, 2007 Lets call the two points P1 and P2 for convenience:1. compute a second line equation that passes through the two points2. Find the intersection of the two infinite lines. If no intersection, you are done.3. If the two lines intersect, compute the coordinate of the intersection point, and call it PInt4. Compute a vector V = PInt - P15. Let L = P2 - P16. If the dot product of V and L is negative, then the intersection point is on the opposite side of L from P2, and so is off the line7. If the dot product of V and L is positive, then the intersection point is on the same side as P2 and might be on the line, so....8. ...compare the square of the length of V and the square of the length of L. If the square of the length of V is less than or equal to the square of the length of L, then the intersection point lies on L, otherwise, the intersection point is further away than P2 and therefore is off of L.Hope that helps! 0 Share this post Link to post Share on other sites
DesignerX 174 Report post Posted August 3, 2007 thx alot man. 0 Share this post Link to post Share on other sites