This content has been marked as final.
Show 3 replies

1. Re: Determining intersection of two lines not working as intended ...
rp0428 Oct 28, 2012 9:22 AM (in response to 835847)>
Any ideas about how I may go about building such a test?
>
You already defined the ruleset for the test in your description. See if Java thinks they intersect. If they don't you have your answer. Otherwise you have to check all four endpoints to see if any of them fall on the other line segment.
1. use intersectsLine  if false then segments do not interesect  you are done, else go to step 2
2. check each endpont of segment 1 to see if it matches either endpoint of segment 2  if true segments do not intersect based on YOUR definition  you are done, else go to step 3
3. use ptSegDist to measure the distance from each endpoint of segment 1 from segment 2  if 0 segments do not intersect based on YOUR definition  you are done, else go to step 4
4. use ptSegDist to measure the distance from each endpoint of segment 2 from segment 1  if 0 segments do not intersect based on YOUR definition  you are done, else go to step 5
5. segments intersect based on YOUR definition 
2. Re: Determining intersection of two lines not working as intended ...
835847 Oct 28, 2012 2:59 PM (in response to rp0428)Thank you for your response. I did exactly what you stated before reading your response. I test if the starting or ending endpoints of a line segment are joined to another line segments starting or ending points. If so, then the lines do not intersect. I believe the reason I had to do this is because Java's intersectsLine(Line2D) method assumes the lines are infinite in length and thus if extending two lines through common endpoints, one can force them to intersect at a common point. 
3. Re: Determining intersection of two lines not working as intended ...
800268 Oct 30, 2012 8:15 AM (in response to 835847)Always Learning wrote:
No it does not assume that. As said by rp0428, it uses a different definition of intersection then yours where the lines like T (and not only like X or +) intersect. The T lines touch, the X lines cross; both intersect.
I believe the reason I had to do this is because Java's intersectsLine(Line2D) method assumes the lines are infinite in length and thus if extending two lines through common endpoints, one can force them to intersect at a common point.