{"id":213,"date":"2009-03-08T00:00:57","date_gmt":"2009-03-08T07:00:57","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=908"},"modified":"2009-03-08T00:00:57","modified_gmt":"2009-03-08T07:00:57","slug":"gumowski-mira","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=213","title":{"rendered":"Gumowski \/ Mira"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(width = 600, height = 600)]\r\nvar a:Number = 0.02;\r\nvar b:Number = .9998;\r\n\r\nvar xn1:Number = 5;\r\nvar yn1:Number = 0;\r\nvar xn:Number, yn:Number;\r\n\r\nvar scale:Number = 10;\r\nvar iterations:Number = 20000;\r\n\r\nfunction f(x:Number):Number{\r\n\tvar x2:Number = x * x;\r\n\treturn a * x + (2 * (1 - a) * x2) \/ (1 + x2);\r\n}\r\n \r\nvar canvas:BitmapData = Bitmap(addChild(new Bitmap(new BitmapData(600,600,false,0xEFEFEF)))).bitmapData;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t\r\n    canvas.fillRect(canvas.rect, 0xEFEFEF);\r\n\ta = mouseY \/ 1000;\r\n\txn1 = mouseX \/ 30;\r\n\tyn1 = 0;\r\n\tfor (var i:int = 0; i&lt;iterations; i++){\r\n\t\t  xn = xn1;\r\n\t\t  yn = yn1;\r\n\t\t  \r\n          xn1 = b * yn + f(xn);\r\n          yn1 =  -xn + f(xn1);\r\n\t\t  canvas.setPixel( 280 + xn1 * scale, 300 + yn1 * scale, 0x000000);\r\n\t}\r\n}\r\n<\/pre>\n<p><i>Notice the setup for this is very similar to yesterdays flames attractor post.<\/i><\/p>\n<p>Back in october of last year I stumbled upon the excellent <a href=\"http:\/\/www.subblue.com\/\">subblue<\/a> website by Tom Beddard. I was REALLY impressed by a <a href=\"http:\/\/www.subblue.com\/blog\/2008\/9\/25\/gumowski-mira_patterns\">blog post about Gumowski \/ Mira patterns<\/a>. If you haven&#8217;t seen it you should go take a look. <\/p>\n<p>I&#8217;d never heard of Gumowski \/ Mira patterns before and made a mental note to go and try to read about them and maybe find an equation to port to actionscript or processing. Anyway, a few days ago I decided to go ahead and look up the math and&#8230; this is the result.<\/p>\n<p><a href=\"http:\/\/mathworld.wolfram.com\/MiraFractal.html\">I got equation over at mathworld&#8230;<\/a><\/p>\n<p>For simplicity I intentionally made the actionscript code look as much like the mathworld equation as possible. Using <b>f<\/b> for my function name and using xn1, yn1 etc&#8230; There are a few speed optimizations that could be made but I wanted this snippet to be very readable.<\/p>\n<p>Here are a few examples of what this code will generate:<br \/>\n<img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/mira_example.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;SWF(width = 600, height = 600)] var a:Number = 0.02; var b:Number = .9998; var xn1:Number = 5; var yn1:Number = 0; var xn:Number, yn:Number; var scale:Number = 10; var iterations:Number = 20000; function f(x:Number):Number{ var x2:Number = x * x; return a * x + (2 * (1 &#8211; a) * x2) \/ (1 [&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,26],"tags":[3,4],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-math","category-setpixel","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/213","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=213"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}