Cody

# Problem 1446. Minimum Distance Point to Segment

Solution 1227436

Submitted on 9 Jul 2017 by Chris Cleveland
• Size: 9
• This is the leading solution.
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
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)] d = 1

8   Pass
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)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In distP2S (line 2) In ScoringEngineTestPoint8 (line 4) In solutionTest (line 17)] d = 1