Cody

Problem 1935. Spherical surface triangulation

Solution 2265254

Submitted on 8 May 2020 by Vedrana Dahl
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: 162 vertices; 320 faces; score = 283.331220 200: 252 vertices; 500 faces; score = 320.219477 300: 362 vertices; 720 faces; score = 332.545409 400: 492 vertices; 980 faces; score = 364.207866 500: 642 vertices; 1280 faces; score = 378.278113 600: 642 vertices; 1280 faces; score = 378.278113 700: 812 vertices; 1620 faces; score = 383.159157 800: 812 vertices; 1620 faces; score = 383.159157 900: 1002 vertices; 2000 faces; score = 398.184120 1000: 1002 vertices; 2000 faces; score = 398.184120 Elapsed time is 0.669541 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!