Cody

# Problem 2100. distance to a straight line (2D) given any 2 distinct points on this straight line

Solution 3760398

Submitted on 21 Nov 2020
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   Fail
p1=[-1;0]; p2=[2;3]; pe=[-2;0]; d=round(1e+6*dist2line(p1,p2,pe))/1e+6; assert(isequal(d,7.071070e-01))

ans = 1.0000 1.0000

Output argument "d" (and maybe others) not assigned during call to "dist2line". Error in Test1 (line 5) d=round(1e+6*dist2line(p1,p2,pe))/1e+6;

2   Fail
p1=[-1;0]; p2=[2;3]; pe=[-0.8;0.1]; d=round(1e+6*dist2line(p1,p2,pe))/1e+6; assert(isequal(d,7.071100e-02))

ans = 1.0000 1.0000

Output argument "d" (and maybe others) not assigned during call to "dist2line". Error in Test2 (line 5) d=round(1e+6*dist2line(p1,p2,pe))/1e+6;

3   Fail
p1=[-1;0]; p2=[2;3]; pe=[0;0.9]; d=round(1e+6*dist2line(p1,p2,pe))/1e+6; assert(isequal(d,7.071100e-02))

ans = 1.0000 1.0000

Output argument "d" (and maybe others) not assigned during call to "dist2line". Error in Test3 (line 5) d=round(1e+6*dist2line(p1,p2,pe))/1e+6;

4   Fail
p1=[0;-1]; p2=[0;1]; pe=[-pi;100]; d=round(1e+6*dist2line(p1,p2,pe))/1e+6; assert(isequal(d,3.141593))

[Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.] [> In polyfit (line 83) In dist2line (line 2) In ScoringEngineTestPoint4 (line 5) In solutionTest (line 9)] ans = 1.0e-15 * 0 0.2346

Output argument "d" (and maybe others) not assigned during call to "dist2line". Error in Test4 (line 5) d=round(1e+6*dist2line(p1,p2,pe))/1e+6;

5   Fail
p1=[-1;0]; p2=[2;3]; pe=[0;1]; d=round(1e+6*dist2line(p1,p2,pe))/1e+6; assert(isequal(d,0))

ans = 1.0000 1.0000

Output argument "d" (and maybe others) not assigned during call to "dist2line". Error in Test5 (line 5) d=round(1e+6*dist2line(p1,p2,pe))/1e+6;

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!