{"id":11854,"date":"2020-12-11T16:56:23","date_gmt":"2020-12-11T21:56:23","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=11854"},"modified":"2020-12-11T16:56:23","modified_gmt":"2020-12-11T21:56:23","slug":"leaf-pile-3d","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2020\/12\/11\/leaf-pile-3d\/","title":{"rendered":"Leaf Pile 3D"},"content":{"rendered":"<div xmlns:mwsh=\"http:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>'s pick this week is <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/79727\">leafpile3d<\/a> by <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/9069783\">Nathaniel Barlow<\/a> and the <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/83443\">extended version with drag<\/a> by <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8264606\">Chris Verhoek<\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <p>Last year I <a href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/10\/04\/leaf-pile\/\">picked leaf pile<\/a> which generated pretty leaves in 2d.  Well now there are 3d options!  Nathaniel has extended the 2d version to show the leaves\r\n      falling with gravity.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">leafpile3D(60)<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/lp3.gif\"> <\/p>\r\n   <p>However, it appears he wrote this so that his students could extend it and add physics to it.  I don't know of Chris is one\r\n      of his students or not, but he extended it and added variable drag based on leaf type, and rotation.  I find I'm just sitting\r\n      here waiting for that last leaf to hit the ground.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">leafpile3Dd(30) <span style=\"color: #228B22\">% added d at end to disambiguate<\/span><\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/lp3d.gif\"> <\/p>\r\n   <p>I also like some of the code changes that Chris made.  Specifically, keeping one command per line and splitting some of the\r\n      longer lines into multiple for readability or better interpretability with source control.\r\n   <\/p>\r\n   <p>You can see a comparison of the two files in MATLAB by selecting them and comparing to each other or by calling <tt>visdiff<\/tt>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">visdiff(<span style=\"color: #A020F0\">\"leafpile3D.m\"<\/span>, <span style=\"color: #A020F0\">\"leafpile3Dd.m\"<\/span>)<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/lp3visdiff.png\"> <\/p>\r\n   <h3>Comments<a name=\"5\"><\/a><\/h3>\r\n   <p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=11854#respond\">here<\/a> or leave a <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/79727#comments\">comment<\/a> for Nathaniel or <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/83443#comments\">comment<\/a> for Chris.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_ca7c5ec6db71478d823236b0d9ed6390() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='ca7c5ec6db71478d823236b0d9ed6390 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ca7c5ec6db71478d823236b0d9ed6390';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Sean de Wolski';\r\n        copyright = 'Copyright 2020 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><br><br>\r\n      Published with MATLAB&reg; R2020b<br><\/p>\r\n<\/div>\r\n<!--\r\nca7c5ec6db71478d823236b0d9ed6390 ##### SOURCE BEGIN #####\r\n%% Leaf Pile 3D\r\n%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s\r\n% pick this week is\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/79727 leafpile3d> by\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/9069783 Nathaniel\r\n% Barlow> and the\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/83443 extended\r\n% version with drag> by\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8264606 Chris\r\n% Verhoek>.\r\n\r\n%% \r\n% Last year I <https:\/\/blogs.mathworks.com\/pick\/2019\/10\/04\/leaf-pile\/\r\n% picked leaf pile> which generated pretty leaves in 2d.  Well now there\r\n% are 3d options!  Nathaniel has extended the 2d version to show the leaves\r\n% falling with gravity.\r\n\r\nleafpile3D(60)\r\n\r\n%%\r\n%\r\n% <<lp3.gif>>\r\n%\r\n% However, it appears he wrote this so that his students could extend it\r\n% and add physics to it.  I don't know of Chris is one of his students or\r\n% not, but he extended it and added variable drag based on leaf type, and\r\n% rotation.  I find I'm just sitting here waiting for that last leaf to\r\n% hit the ground.\r\n%\r\n\r\nleafpile3Dd(30) % added d at end to disambiguate\r\n\r\n%%\r\n%\r\n% <<lp3d.gif>>\r\n%\r\n% I also like some of the code changes that Chris made.  Specifically,\r\n% keeping one command per line and splitting some of the longer lines into\r\n% multiple for readability or better interpretability with source control.\r\n%\r\n% You can see a comparison of the two files in MATLAB by selecting them and\r\n% comparing to each other or by calling |visdiff|.\r\n%\r\n\r\nvisdiff(\"leafpile3D.m\", \"leafpile3Dd.m\")\r\n\r\n%%\r\n%\r\n% <<lp3visdiff.png>>\r\n\r\n%% Comments\r\n% \r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=11854#respond here> or leave a\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/79727#comments\r\n% comment> for Nathaniel or <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/83443#comments\r\n% comment> for Chris.\r\n%\r\n \r\n\r\n##### SOURCE END ##### ca7c5ec6db71478d823236b0d9ed6390\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/lp3.gif\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is leafpile3d by Nathaniel Barlow and the extended version with drag by Chris Verhoek.\r\n      \r\n   \r\n   Last year I picked leaf pile which generated pretty leaves... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2020\/12\/11\/leaf-pile-3d\/\">read more >><\/a><\/p>","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11854"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=11854"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11854\/revisions"}],"predecessor-version":[{"id":11868,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11854\/revisions\/11868"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=11854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=11854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=11854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}