{"id":9474,"date":"2018-02-16T09:14:23","date_gmt":"2018-02-16T14:14:23","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=9474"},"modified":"2018-02-16T09:14:23","modified_gmt":"2018-02-16T14:14:23","slug":"fruit-package","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2018\/02\/16\/fruit-package\/","title":{"rendered":"Fruit Package"},"content":{"rendered":"\r\n<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66017-a-simple-fruit-package\">A simple fruit package<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4155636\">kim9091<\/a>.<\/p><p>This one is a fun and well-written example of 3D graphics using basic patch objects. You can draw 13 different kinds of fruits with ability to specify geometric parameters. For example, here&#8217;s a strawberry.<\/p><pre class=\"codeinput\">s = fruit.strawberry([0 0 0], 5);\r\nview(3)\r\nlight\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fruit_package\/potw_fruit_package_01.png\" alt=\"\"> <p>To change the orientation, you simply use the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/rotate.html\"><tt>rotate<\/tt><\/a> function.<\/p><pre class=\"codeinput\">rotate(s,[0 1 0],-45)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fruit_package\/potw_fruit_package_02.png\" alt=\"\"> <p>Let&#8217;s place a slice of lemon on the side.<\/p><pre class=\"codeinput\">l = fruit.lemon([5 8 0],10);\r\nrotate(l,[1 0 0],-45)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fruit_package\/potw_fruit_package_03.png\" alt=\"\"> <p>Now, enjoy your fruit plate! (from the FEX entry)<\/p><p>\r\n<img decoding=\"async\" src=\"https:\/\/www.mathworks.com\/matlabcentral\/mlc-downloads\/downloads\/submissions\/66017\/versions\/1\/screenshot.jpg\" width=\"1000\">\r\n<\/p><p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=9474#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66017-a-simple-fruit-package#comment\">comment<\/a> for kim9091.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_8e409505661f492dad8d20d572c2b32c() {\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='8e409505661f492dad8d20d572c2b32c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 8e409505661f492dad8d20d572c2b32c';\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        copyright = 'Copyright 2018 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 copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\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     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_8e409505661f492dad8d20d572c2b32c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2017b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2017b<br><\/p><\/div><!--\r\n8e409505661f492dad8d20d572c2b32c ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/\/matlabcentral\/profile\/authors\/869871 Jiro>'s\r\n% pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66017-a-simple-fruit-package A simple\r\n% fruit package> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4155636\r\n% kim9091>.\r\n%\r\n% This one is a fun and well-written example of 3D graphics using basic\r\n% patch objects. You can draw 13 different kinds of fruits with ability to\r\n% specify geometric parameters. For example, here's a strawberry.\r\n\r\ns = fruit.strawberry([0 0 0], 5);\r\nview(3)\r\nlight\r\n\r\n%%\r\n% To change the orientation, you simply use the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/rotate.html |rotate|>\r\n% function.\r\n\r\nrotate(s,[0 1 0],-45)\r\n\r\n%%\r\n% Let's place a slice of lemon on the side.\r\n\r\nl = fruit.lemon([5 8 0],10);\r\nrotate(l,[1 0 0],-45)\r\n%%\r\n% Now, enjoy your fruit plate! (from the FEX entry)\r\n% \r\n% <html>\r\n% <img decoding=\"async\" src=\"https:\/\/www.mathworks.com\/matlabcentral\/mlc-downloads\/downloads\/submissions\/66017\/versions\/1\/screenshot.jpg\" width=\"1000\">\r\n% <\/html>\r\n%\r\n% *Comments*\r\n%\r\n% Give it a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=9474#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66017-a-simple-fruit-package#comment\r\n% comment> for kim9091.\r\n\r\n##### SOURCE END ##### 8e409505661f492dad8d20d572c2b32c\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fruit_package\/potw_fruit_package_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nJiro&#8216;s pick this week is A simple fruit package by kim9091.This one is a fun and well-written example of 3D graphics using basic patch objects. You can draw 13 different kinds of fruits with&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2018\/02\/16\/fruit-package\/\">read more >><\/a><\/p>","protected":false},"author":35,"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\/9474"}],"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\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=9474"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/9474\/revisions"}],"predecessor-version":[{"id":9478,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/9474\/revisions\/9478"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=9474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=9474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=9474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}