Cody

# Problem 1720. Do the lines intersect?

Solution 1626730

Submitted on 13 Sep 2018 by Suraj Gurav
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
a = [0,0; 1,1]; b = [0,1; 1,0]; tf_correct = true; assert(isequal(intersecting(a,b),tf_correct ))

m1 = 1 m2 = -1 b1 = 0 b2 = 1 lineEq = function_handle with value: @(m,c,myline)m*myline(:,1)+c yEst2 = 0 1 enderr = function_handle with value: @(ends,line)ends-line(:,2) errs1 = -1 1 yEst1 = 1 0 errs2 = 1 -1 tf = logical 1

2   Pass
a = [0,0; 1,0]; b = [0,1; 1,1]; tf_correct = false; assert(isequal(intersecting(a,b),tf_correct ))

m1 = 0 m2 = 0 b1 = 0 b2 = 1 lineEq = function_handle with value: @(m,c,myline)m*myline(:,1)+c yEst2 = 0 0 enderr = function_handle with value: @(ends,line)ends-line(:,2) errs1 = -1 -1 yEst1 = 1 1 errs2 = 1 1 tf = logical 0

3   Pass
a = [0,0; 1,0]; b = [2,0; 3,0]; tf_correct = false; assert(isequal(intersecting(a,b),tf_correct ))

tf = logical 0

4   Pass
a = [4 3;6 8]; b = [3 7;6 9]; tf_correct = false; assert(isequal(intersecting(a,b),tf_correct ))

m1 = 2.5000 m2 = 0.6667 b1 = -7 b2 = 5 lineEq = function_handle with value: @(m,c,myline)m*myline(:,1)+c yEst2 = 0.5000 8.0000 enderr = function_handle with value: @(ends,line)ends-line(:,2) errs1 = -6.5000 -1.0000 yEst1 = 7.6667 9.0000 errs2 = 4.6667 1.0000 tf = logical 0

5   Pass
a = [6 2;6 9]; b = [7 6;4 5]; tf_correct = true; assert(isequal(intersecting(a,b),tf_correct ))

tf = logical 1

6   Pass
a = [3 -3;-2 -2]; b = [-1 1;0 -4]; tf_correct = true; assert(isequal(intersecting(a,b),tf_correct ))

m1 = -0.2000 m2 = -5 b1 = -2.4000 b2 = -4 lineEq = function_handle with value: @(m,c,myline)m*myline(:,1)+c yEst2 = -2.2000 -2.4000 enderr = function_handle with value: @(ends,line)ends-line(:,2) errs1 = -3.2000 1.6000 yEst1 = -19 6 errs2 = -16 8 tf = logical 1