{"id":259,"date":"2009-04-19T22:09:10","date_gmt":"2009-04-20T05:09:10","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1187"},"modified":"2009-04-19T22:09:10","modified_gmt":"2009-04-20T05:09:10","slug":"hypocycloid-spiral","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=259","title":{"rendered":"Hypocycloid Spiral"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nx = stage.stageWidth \/ 2;\r\ny = stage.stageHeight \/ 2;\r\n\/\/ change n to alter number of spikes (cuspes)\r\nvar n:Number = 8;\r\nvar xp:Number = 0, yp:Number = 0, a:Number = 10, t:Number = 0;\r\n\r\ngraphics.lineStyle(0, 0x000000);\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\tfor (var i:int = 0; i&lt;10; i++){\r\n\t  \/\/ unoptimized for simplicity and similarity to original equations from here:\r\n          \/\/ http:\/\/mathworld.wolfram.com\/Hypocycloid.html\r\n      xp = a\/n * ((n - 1) * Math.cos(t) + Math.cos(Math.abs((n - 1) * t)));\r\n\t  yp = a\/n * ((n - 1) * Math.sin(t) - Math.sin(Math.abs((n - 1) * t)))  ;\r\n\t  \r\n\t  a *= 1.002;\r\n\t   if (t == 0){\r\n\t\t   graphics.moveTo(xp, yp);\r\n\t   }else{\r\n\t\t   graphics.lineTo(xp, yp);   \r\n\t   }\r\n\t   t += .1;\r\n\t}\r\n}\r\n<\/pre>\n<p>This code draws a Hypocycloid with a radius that increments &#8211; this results in a spiral formation. <\/p>\n<p>I got the math from mathworld&#8230; <a href=\"http:\/\/mathworld.wolfram.com\/Hypocycloid.html\" target=\"blank\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>x = stage.stageWidth \/ 2; y = stage.stageHeight \/ 2; \/\/ change n to alter number of spikes (cuspes) var n:Number = 8; var xp:Number = 0, yp:Number = 0, a:Number = 10, t:Number = 0; graphics.lineStyle(0, 0x000000); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { for (var i:int = 0; i&lt;10; i++){ \/\/ unoptimized for simplicity and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121],"tags":[3,4],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-math","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/259","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=259"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/259\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}