{"id":485,"date":"2010-03-03T12:26:33","date_gmt":"2010-03-03T19:26:33","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2768"},"modified":"2010-03-03T12:26:33","modified_gmt":"2010-03-03T19:26:33","slug":"polar-coordinates-distribution","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=485","title":{"rendered":"Polar Coordinates Distribution"},"content":{"rendered":"<p>If you&#8217;re at all interested in watching me free from code. I recorded a video of me coding this snippet (which is about 11 minutes long or so).<\/p>\n<p>In the video I create a few functions that allow you to draw shapes like these:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/polar_coord_distribution.gif\"\/><\/p>\n<p>Mathematically this stuff is really simple &#8230; the free form nature of the video takes a less technical perspective as you&#8217;ll see (I even made a few funny mistakes). <\/p>\n<p><a href=\"https:\/\/actionsnippet.com\/vids\/polar_vid.html\" target=\"blank\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/impropvid.gif\" \/><br \/>\n<\/a> <\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(width = 600, height = 600)]\r\nvar dotNum:int = 1000;\r\nvar dotRad:Number = 0.5;\r\n\r\nx = 120\r\ny = 100;\r\n\r\n\/\/ extra stuff to display what the functions can do\r\nstage.addEventListener(MouseEvent.CLICK, onDrawAll);\r\n\r\nfunction onDrawAll(evt:Event):void{\r\n\tgraphics.clear();\r\n\tfor (var i:int = 0; i&lt;16; i++){\r\n\t\tvar m:Number;\r\n\t\r\n\t\tvar rad:Number = 120;\r\n\t\tvar xp:Number = i % 4 * rad\r\n\t\tvar yp:Number = int(i \/ 4) * rad\r\n\t\r\n\t\tvar type:int = int(Math.random() * 4);\r\n\t\tif (type == 0){\r\n\t\t  makeShape(xp, yp, rad-60, Math.random() , 1);\r\n\t\t}else if (type == 1){\r\n\t\t   makeShape(xp, yp, rad-60, 1,  Math.random());\r\n\t\t}\r\n\t\telse if (type == 2){\r\n\t\t   m = Math.random() * 2;\r\n\t\t   makeShape(xp, yp, rad-Math.random()*120, m, m);\r\n\t\t}\r\n\t\telse if (type == 3){\r\n\t\t   m = Math.random() * 2;\r\n\t\t   makeShape(xp, yp, rad-Math.random()*120, m, m\/2);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\/\/ main part from the video \r\nfunction makeShape(xp:Number, yp:Number, \r\n\t\t\t\t   maxRad:Number = 100,m0:Number=1, \r\n\t\t\t\t   m1:Number=1):void{\r\n\tvar polarX:Number;\r\n\tvar polarY:Number;\r\n\tvar radius:Number;\r\n\tgraphics.lineStyle(0, 0);\r\n\tvar theta:Number = Math.random() * Math.PI * 2;\r\n\tfor (var i:int = 0; i&lt;dotNum; i++){\r\n\t\tradius = Math.random() * maxRad\r\n\t\tpolarX = xp + radius * Math.cos(theta * m0);\r\n\t\tpolarY = yp + radius * Math.sin(theta * m1);\r\n\t\ttheta += 0.1;\r\n\t\t \r\n\t\tmakeDot(polarX, polarY);\r\n\t\t\r\n\t}\r\n}\r\n\r\nfunction makeDot(xp:Number, yp:Number, fillColor:uint = 0x000000):void{\r\n\tgraphics.beginFill(fillColor);\r\n\tgraphics.drawCircle(xp, yp, dotRad);\r\n\tgraphics.endFill();\r\n}\r\n<\/pre>\n<p>Here it is over at wonderf:<\/p>\n<div style=\"text-align:center;width:465px;\"><iframe loading=\"lazy\" title=\"Polar Distribution - wonderfl build flash online\" scrolling=\"no\" src=\"http:\/\/wonderfl.net\/blogparts\/159a0fd942a8fd3dc007a002df896dd3c34f55c6\" width=\"465\" height=\"490\" style=\"border:1px black solid;\"><\/iframe><a href=\"http:\/\/wonderfl.net\/code\/159a0fd942a8fd3dc007a002df896dd3c34f55c6\" title=\"Polar Distribution - wonderfl build flash online\">Polar Distribution &#8211; wonderfl build flash online<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re at all interested in watching me free from code. I recorded a video of me coding this snippet (which is about 11 minutes long or so). In the video I create a few functions that allow you to draw shapes like these: Mathematically this stuff is really simple &#8230; the free form nature [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,33,121,94],"tags":[3,14,4],"class_list":["post-485","post","type-post","status-publish","format-standard","hentry","category-functions","category-graphics","category-math","category-misc","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/485\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}