Cody

# Problem 44910. Find the centre of an arc and its radius

Solution 2170267

Submitted on 22 Mar 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
x0 = 1; y0 = 0; x1 = 0; y1 = 1; a = 90; [x,y,r] = arc_centre(x0,y0,x1,y1,a); x_correct = 0; y_correct = 0; r_correct = 1; tol=0.00001; assert(ismembertol(x,x_correct,tol)) assert(ismembertol(y,y_correct,tol)) assert(ismembertol(r,r_correct,tol))

r = 1 a1 = 1 A1 = 0 B1 = -2 C1 = -0.5000 ans = -0.2500

Output argument "x" (and maybe others) not assigned during call to "arc_centre". Error in Test1 (line 6) [x,y,r] = arc_centre(x0,y0,x1,y1,a);

2   Fail
x0 = 0; y0 = 1; x1 = 1; y1 = 0; a = 270; [x,y,r] = arc_centre(x0,y0,x1,y1,a); x_correct = 0; y_correct = 0; r_correct = 1; tol=0.00001; assert(ismembertol(x,x_correct,tol)) assert(ismembertol(y,y_correct,tol)) assert(ismembertol(r,r_correct,tol))

r = 1 a1 = 1 A1 = 0 B1 = 2 C1 = -0.5000 ans = 0.2500

Output argument "x" (and maybe others) not assigned during call to "arc_centre". Error in Test2 (line 6) [x,y,r] = arc_centre(x0,y0,x1,y1,a);

3   Fail
x0 = 1; y0 = 1; x1 = -1; y1 = 1; a = 45; [x,y,r] = arc_centre(x0,y0,x1,y1,a); x_correct = 0; y_correct = -sqrt(2); r_correct = sqrt(1+(sqrt(2)+1)^2); tol=0.00001; assert(ismembertol(x,x_correct,tol)) assert(ismembertol(y,y_correct,tol)) assert(ismembertol(r,r_correct,tol))

r = 2.6131 a1 = Inf A1 = -Inf B1 = -Inf C1 = Inf

Error using roots (line 27) Input to ROOTS must not contain NaN or Inf. Error in arc_centre (line 11) roots([A1 B1 C1]) Error in Test3 (line 6) [x,y,r] = arc_centre(x0,y0,x1,y1,a);