Cody

# Problem 1651. Circumcircle Points

Solution 278962

Submitted on 11 Jul 2013
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
%% pts=[0 0;5 0;1.8 2.4]; % 3 4 5 triangle r_exp=2.5; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

2   Fail
%% pts=[0 0;6 0;1.8 2.4]; % 3 x 6 triangle r_exp=3; % Two Point Solver r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

3   Pass
%% pts=[0 0;0 1;1 2;3 0]; % r^2=2.5 r_exp=sqrt(2.5); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

4   Fail
%% pts=[0 1; 0 3; 0 4; 2 6; 3 0; 4 5]; % r2 9.2820069 r_exp=sqrt(9.2820069 ); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

5   Fail
%% pts=[0,2;0,6;1,1;3,0;3,3;4,10;5,10;7,2;9,7]; % r2 26.6919 r_exp=sqrt(26.6919420552286 ); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

6   Fail
%% pts=[0,19;1,25;1,30;1,34;3,11;4,30;8,17;9,6;11,44;12,45;15,46;21,0;21,9;21,48;22,42;26,11;31,40;34,27;37,44;39,34;41,8;43,9;43,10;46,16;46,35;48,23]; % r2 exp 608.7807 r_exp=sqrt(608.780718525455); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

7   Pass
%% % Random case to avoid hard coders xc=rand; yc=rand; r=.5+rand; pts=[]; % Equilateral points pts(1,:)=[xc+r,yc]; pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)]; pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)]; for i=4:10 rnew=rand*r; theta=randi(360)*pi/180; pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)]; end pts=pts(randperm(size(pts,1)),:); r_exp=r; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

8   Fail
%% % Random case to avoid hard coders xc=rand; yc=rand; r=.5+rand; pts=[]; % Equilateral points pts(1,:)=[xc+r,yc]; pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)]; pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)]; for i=4:30 rnew=rand*r; theta=randi(360)*pi/180; pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)]; end pts=pts(randperm(size(pts,1)),:); r_exp=r; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

Error: Assertion failed.

### Community Treasure Hunt

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

Start Hunting!