Cody

Problem 1935. Spherical surface triangulation

Solution 2626147

Submitted on 29 Jun 2020 by Rafael S.T. Vieira
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: 258 vertices; 512 faces; score = 538.054179 200: 258 vertices; 512 faces; score = 538.054179 300: 1026 vertices; 2048 faces; score = 553.961671 400: 1026 vertices; 2048 faces; score = 553.961671 500: 1026 vertices; 2048 faces; score = 553.961671 600: 1026 vertices; 2048 faces; score = 553.961671 700: 1026 vertices; 2048 faces; score = 553.961671 800: 1026 vertices; 2048 faces; score = 553.961671 900: 1026 vertices; 2048 faces; score = 553.961671 1000: 1026 vertices; 2048 faces; score = 553.961671 Elapsed time is 0.630172 seconds.

Suggested Problems

More from this Author38

Community Treasure Hunt

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

Start Hunting!