{"id":3398,"date":"2012-03-19T11:30:24","date_gmt":"2012-03-19T16:30:24","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=3398"},"modified":"2012-03-19T11:30:24","modified_gmt":"2012-03-19T16:30:24","slug":"playing-billiards-in-matlab","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2012\/03\/19\/playing-billiards-in-matlab\/","title":{"rendered":"Playing Billiards in MATLAB"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction><\/introduction>\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31556-matlab-pool\">pool,<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31593\">Husam Aldahiyat<\/a>.\r\n   <\/p>\r\n   <p>Today's quick Pick is all about escapism.<\/p>\r\n   <p>Back in grad school, I used to enjoy sipping a home-brew and shooting pool in my living room. Friends would come over, and\r\n      we'd play for hours. Inevitably, the \"real world\" rears its head. I now have children, I haven't brewed beer in many years,\r\n      and my wife won't let me have a pool table in my living room. (Of course, the kids are their own reward, but I can still reminisce,\r\n      can't I?)\r\n   <\/p>\r\n   <p>Husam's entry brought me back, for a few moments, to halcyon days, drinking beer and playing billiards. And it brought a smile\r\n      to my face.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/poolscreenshot.png\"> <\/p>\r\n   <p>Simply type <tt>pool<\/tt> at your MATLAB prompt, and you'll be presented with a 3D-rotatable pool table. You can specify the shooting angle and stroke\r\n      force, and press a button to shoot. Sink all six balls in any order without scratching, and you win!\r\n   <\/p>\r\n   <p>Thanks, Husam. You brightened my day!<\/p>\r\n   <p>As always, <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=3398#respond\">comments to this blog post<\/a> are welcome. Or leave a comment for Husam <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31556-matlab-pool#comments\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_1219d5ab5a6944d381b82e26f4a6aa6a() {\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='1219d5ab5a6944d381b82e26f4a6aa6a ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1219d5ab5a6944d381b82e26f4a6aa6a';\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 = 'Brett Shoelson';\r\n        copyright = 'Copyright 2012 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><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_1219d5ab5a6944d381b82e26f4a6aa6a()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.14<br><\/p>\r\n<\/div>\r\n<!--\r\n1219d5ab5a6944d381b82e26f4a6aa6a ##### SOURCE BEGIN #####\r\n%% Playing Billiards in MATLAB\r\n%% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>'s Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31556-matlab-pool pool,> by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31593 Husam Aldahiyat>.\r\n\r\n%%\r\n% Today's quick Pick is all about escapism.\r\n\r\n%% \r\n% Back in grad school, I used to enjoy sipping a home-brew\r\n% and shooting pool in my living room. Friends would come\r\n% over, and we'd play for hours. Inevitably, the \"real\r\n% world\" rears its head. I now have children, I haven't brewed\r\n% beer in many years, and my wife won't let me have a pool table in\r\n% my living room. (Of course, the kids are their own reward,\r\n% but I can still reminisce, can't I?)\r\n\r\n%% \r\n% Husam's entry brought me back, for a few moments, to \r\n% halcyon days, drinking beer and playing billiards. And it\r\n% brought a smile to my face.\r\n\r\n%%\r\n% \r\n% <<https:\/\/blogs.mathworks.com\/pick\/files\/poolscreenshot.png>>\r\n% \r\n\r\n%%\r\n% Simply type |pool| at your MATLAB prompt, and you'll be presented with a\r\n% 3D-rotatable pool table. You can specify the shooting\r\n% angle and stroke force, and press a button to shoot. Sink\r\n% all six balls in any order without scratching, and you\r\n% win!\r\n\r\n%%\r\n% Thanks, Husam. You brightened my day!\r\n\r\n%% \r\n% As always, <https:\/\/blogs.mathworks.com\/pick\/?p=3398#respond comments to this blog post> are welcome. Or leave a\r\n% comment for Husam\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31556-matlab-pool#comments here>.\r\n\r\n##### SOURCE END ##### 1219d5ab5a6944d381b82e26f4a6aa6a\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n   Brett's Pick this week is pool, by Husam Aldahiyat.\r\n   \r\n   Today's quick Pick is all about escapism.\r\n   Back in grad school, I used to enjoy sipping a home-brew and shooting pool in my... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2012\/03\/19\/playing-billiards-in-matlab\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/3398"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=3398"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3398\/revisions"}],"predecessor-version":[{"id":3408,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3398\/revisions\/3408"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=3398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=3398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=3398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}