Cody

Problem 1446. Minimum Distance Point to Segment

Solution 1950694

Submitted on 27 Sep 2019
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
p=[0 0]; v=[1 -1]; w=[1 1]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d-1)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test1 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

2   Fail
p=[0 0]; v=[-1 2]; w=[1 2]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d-2)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test2 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

3   Fail
p=[0 0]; v=[-1 -1]; w=[1 1]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test3 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

4   Fail
p=[1 1]; v=[0 3]; w=[3 0]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d-1/2^.5)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test4 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

5   Fail
p=[5 0]; v=[0 3]; w=[3 0]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d-2)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test5 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

6   Fail
p=[0 6]; v=[0 3]; w=[3 0]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)); assert(abs(d-3)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test6 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2));

7   Fail
p=[-4 0]; v=[0 3]; w=[-3 0]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)) assert(abs(d-1)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test7 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2))

8   Fail
p=[1 0]; v=[1.01 0]; w=[5 5]; d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2)) assert(abs(d-.01)<.005)

Undefined function 'p' for input arguments of type 'double'. Error in distP2S (line 2) dv = sqrt((p(1)-v(1)).^2 + (p(2)-v(2)).^2); Error in Test8 (line 4) d=distP2S(p(1),p(2),v(1),v(2),w(1),w(2))