Cody

# Problem 450. What is the distance from point P(x,y) to the line Ax + By + C = 0?

Solution 3844413

Submitted on 25 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
x=2; y=2; A=2; B=2; C=-4; y_correct = 1.4142; assert(abs(normalLen(x,y,A,B,C)-y_correct)<=1e-4)

d = 0.8165

Assertion failed.

2   Fail
x=3; y=4; A=3; B=4; C=5; y_correct = 6; assert(normalLen(x,y,A,B,C)-y_correct==0)

d = 4.2426

Assertion failed.

3   Fail
x=4; y=5; A=3; B=4; C=5; y_correct = 7.4; display(normalLen(x,y,A,B,C)) assert(abs(normalLen(x,y,A,B,C)-y_correct)<1e-1)

d = 5.2326 5.2326 d = 5.2326

Assertion failed.

4   Pass
x=0;y=12345;A=0;B=1;C=0; y_correct = 12345; display(normalLen(x,y,A,B,C)) assert(abs(normalLen(x,y,A,B,C)-y_correct)==0)

d = 12345 12345 d = 12345

5   Fail
x=0;y=-12345;A=0;B=1;C=0; y_correct = 12345; display(normalLen(x,y,A,B,C)) assert(abs(normalLen(x,y,A,B,C)-y_correct)==0)

d = -12345 -12345 d = -12345

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!