Cody

Problem 636. Spherical radius given four points

Solution 1929629

Submitted on 10 Sep 2019 by Doan Quang Manh
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
pts=[0 3 2;1 -1 1;2 1 0;5 1 3]; % c(2 1 3) r=3 y_correct = 3; assert(isequal(Sphere_radius(pts),y_correct))

a = 0 -6 -4 1 -2 2 -2 1 -4 -2 0 1 -10 -2 -6 1 b = -13 -3 -5 -35 c = 2.0000 1.0000 3.0000 5.0000 r = 3

2   Pass
pts=[1 0 0;0 1 0;0 0 1;-1 0 0]; % c(0 0 0) r=1 y_correct = 1; assert(isequal(Sphere_radius(pts),y_correct))

a = -2 0 0 1 0 -2 0 1 0 0 -2 1 2 0 0 1 b = -1 -1 -1 -1 c = 0 0 0 -1 r = 1

3   Pass
pts=[1 0 -1;0 1 -1;0 0 0;-1 0 -1]; % c(0 0 -1) r=1 y_correct = 1; assert(isequal(Sphere_radius(pts),y_correct))

a = -2 0 2 1 0 -2 2 1 0 0 0 1 2 0 2 1 b = -2 -2 0 -2 c = 0 0 -1 0 r = 1

4   Pass
pts=[2 0 -2;0 2 -2;0 0 0;-2 0 -2]; % c(0 0 -2) r=2 y_correct = 2; assert(isequal(Sphere_radius(pts),y_correct))

a = -4 0 4 1 0 -4 4 1 0 0 0 1 4 0 4 1 b = -8 -8 0 -8 c = 0 0 -2 0 r = 2

5   Pass
pts=[-5 -1 -3;1 -1 -3;-2 -4 -3;-2 -1 0]; % c(-2 -1 -3) r=3 y_correct = 3; assert(isequal(Sphere_radius(pts),y_correct))

a = 10 2 6 1 -2 2 6 1 4 8 6 1 4 2 0 1 b = -35 -11 -29 -5 c = -2.0000 -1.0000 -3.0000 5.0000 r = 3