Problem 1720. Do the line-segments intersect?
Solution Stats
Problem Comments
-
4 Comments
What about
a = [0,0; 2,2]; b = [1,1; 3,3];
?
Hi Celestino. I added a little bit more clarifying text to the problem statement. That's an interesting test case, but not one I will use for this problem. You could make your own extension to this problem, though!
Test Case 4 should be "true" since these lines intersect.
For Test Case 3, the two lines are on top of each other, so they will technically intersect infinite times :).
@Doddy
The question asks if the "line segments" intersect or not, not the whole line. For lines touching, it is clearly stated in the problem statement, that the line segments should not be overlapping and should intersect only at a single point.
Solution Comments
-
1 Comment
This assumes sorted coordinates.
-
1 Comment
I like the conceptual clarity of this one.
-
1 Comment
For
a = [0,0; 2,2]; b = [1,1; 3,3];
a = [0,0; 2,2]; b = [2,2; 3,3];
Problem Recent Solvers65
Suggested Problems
-
2822 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
443 Solvers
-
743 Solvers
-
Create Volcano (or Atoll) martix. It is an extension of Bullseye matrix problem.
121 Solvers
-
4421 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!