Cody

# Problem 1935. Spherical surface triangulation

Solution 1847394

Submitted on 12 Jun 2019 by Sean Kavanagh
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
urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&amp;d=1','SetSolutionScore.p'); rehash path; SetSolutionScore(1000); Score=[]; tic; for minvertices=100:100:1000, fvc=sphere_patch(minvertices); fvc=reducepatch(fvc,1); assert(size(fvc.vertices,1)>=minvertices,'too few vertices'); assert(size(fvc.faces,1)>=minvertices,'too few faces'); assert(all(abs(1-sum(fvc.vertices.^2,2))<1e-4),'vertices not on the sphere surface'); assert(isequal(unique(fvc.faces),(1:size(fvc.vertices,1))'),'all vertices must be referenced in faces'); d1=sqrt(sum(abs(fvc.vertices(fvc.faces(:,1),:)-fvc.vertices(fvc.faces(:,2),:)).^2,2)); d2=sqrt(sum(abs(fvc.vertices(fvc.faces(:,2),:)-fvc.vertices(fvc.faces(:,3),:)).^2,2)); d3=sqrt(sum(abs(fvc.vertices(fvc.faces(:,3),:)-fvc.vertices(fvc.faces(:,1),:)).^2,2)); s=(d1+d2+d3)/2; a=sqrt(s.*(s-d1).*(s-d2).*(s-d3)); assert(abs(1-sum(a)/4/pi)<.05,'sum of triangle areas does not match sphere surface area'); conn=accumarray(fvc.faces(:,[1,2]),1,size(fvc.vertices,1)*[1 1])+accumarray(fvc.faces(:,[1,3]),1,size(fvc.vertices,1)*[1 1])+accumarray(fvc.faces(:,[2,3]),1,size(fvc.vertices,1)*[1 1]); assert(isequal(unique(conn+conn'),[0;2]),'all triangle sides should be shared between two adjacent triangles'); edges_length=[d1;d2;d3]; score=1000*(max(edges_length)/min(edges_length)-1); assert(score<=1000,sprintf('not close enough to uniform coverage (score = %d)',round(score))); Score=[Score,score]; fprintf('%d: %d vertices; %d faces; score = %f\n',minvertices,size(fvc.vertices,1),size(fvc.faces,1),score); end toc; SetSolutionScore(round(mean(Score)));

100: 101 vertices; 198 faces; score = 678.270989 200: 201 vertices; 398 faces; score = 685.935520 300: 301 vertices; 598 faces; score = 688.490042 400: 401 vertices; 798 faces; score = 689.767245 500: 501 vertices; 998 faces; score = 690.533548 600: 601 vertices; 1198 faces; score = 691.044410 700: 701 vertices; 1398 faces; score = 691.409307 800: 801 vertices; 1598 faces; score = 691.682978 900: 901 vertices; 1798 faces; score = 691.895832 1000: 1001 vertices; 1998 faces; score = 692.066115 Elapsed time is 0.399421 seconds.