# Limited Intersection

This topic is 4120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
Lets call the two points P1 and P2 for convenience:

1. compute a second line equation that passes through the two points
2. 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 PInt
4. Compute a vector V = PInt - P1
5. Let L = P2 - P1
6. 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 line
7. 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!

thx alot man.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633270
• Total Posts
3011159
• ### Who's Online (See full list)

There are no registered users currently online

×