Cody

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

Solution 1408752

Submitted on 7 Jan 2018 by Bob Tivnan
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
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)

t = 2 2 D = 2 2 2 -2 z = 4 0 s = 1 1 d = 1.4142

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

t = 3 4 D = 3 4 4 -3 z = -5 0 s = -0.6000 -0.8000 d = 6

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

t = 4 5 D = 3 4 4 -3 z = -5 1 s = -0.4400 -0.9200 d = 7.4000 7.4000 t = 4 5 D = 3 4 4 -3 z = -5 1 s = -0.4400 -0.9200 d = 7.4000

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)

t = 0 12345 D = 0 1 1 0 z = 0 0 s = 0 0 d = 12345 12345 t = 0 12345 D = 0 1 1 0 z = 0 0 s = 0 0 d = 12345

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

t = 0 -12345 D = 0 1 1 0 z = 0 0 s = 0 0 d = 12345 12345 t = 0 -12345 D = 0 1 1 0 z = 0 0 s = 0 0 d = 12345