{"id":472,"date":"2007-07-17T13:17:49","date_gmt":"2007-07-17T13:17:49","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2007\/07\/17\/fractal-curves-and-coastlines\/"},"modified":"2007-07-17T13:17:49","modified_gmt":"2007-07-17T13:17:49","slug":"fractal-curves-and-coastlines","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2007\/07\/17\/fractal-curves-and-coastlines\/","title":{"rendered":"Fractal Curves and Coastlines"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"Von_Koch_curve.gif\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_205.gif?resize=150%2C156\" width=\"150\" height=\"156\" class=\"inset right\" \/><\/p>\n<p> I just finally got my copy of Mandelbrot&#8217;s book on fractals. In his discussion of curve fractals (that is, fractals formed from an unbroken line, isomorphic to the interval (0,1)), he describes them in terms of shorelines rather than borders. I&#8217;ve got to admit<br \/>\nthat his metaphor is better than mine, and I&#8217;ll adopt it for this post.<\/p>\n<p> In <a href=\"http:\/\/scientopia.org\/blogs\/goodmath\/2007\/07\/fractal-borders\">my last post<\/a>, I discussed the idea of how a border (or, better, a shoreline) has<br \/>\na kind of fractal structure. It&#8217;s jagged, and the jags themselves have jagged edges, and *those* jags have jagged edges, and so on. Today, I&#8217;m going to show a bit of how to<br \/>\ngenerate curve fractals with that kind of structure.<\/p>\n<p><!--more--><br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"koch.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_262.jpg?resize=216%2C227\" width=\"216\" height=\"227\" class=\"inset right\" \/><\/p>\n<p> The canonical example  of a fractal curve is the Koch curve. To generate the canonical Koch curve,<br \/>\nyou take a line segment, divide it into three sections, and replace the middle with<br \/>\nthe upper two edges of an equilateral triangle. Then you repeat that process for each of<br \/>\nthe straight edges in the resulting figure. Over to the side are illustrations of the Koch<br \/>\ncurve after 1, 2, 3, and 4 iterations.<\/p>\n<p> This kind of curve obviously isn&#8217;t ideal as a model of something like a coastline. It&#8217;s perfectly regular, which natural structures like coastlines aren&#8217;t. But it&#8217;s a starting point; we can eventually work irregularity and randomness into these kinds of curves. But<br \/>\nfor now, we&#8217;ll stick with the simple ones.<\/p>\n<p> The Koch curve can be described in terms of a simple grammar, which guides<br \/>\na recursive rewrite system. (In fact, that&#8217;s how I implemented the code to generate<br \/>\nthe diagrams for this post: I&#8217;ve got a simple rewrite system, and I&#8217;m feeding the<br \/>\nresults into a turtle drawing program which traces out the curve.)<\/p>\n<p> In a rewrite system for fractal curves, you start with a grammar symbol called<br \/>\nthe <em>initiator<\/em>, and then specify a rule system called the <em>generator<\/em>. The generator is a set of replacement rules. Each iteration of the algorithm, you scan through the current state of the curve (starting with the initiator on step 0), and<br \/>\neach time that you encounter a symbol which is the left hand side of a rule in the generator, you replace that symbol with the right hand side of the corresponding rule.<\/p>\n<p> For example, the Koch curve is specified by:<\/p>\n<ul>\n<li> Initiator: line<\/li>\n<li> Generator: line &rarr; line,left(60),line,right(120),line,left(60),line<\/li>\n<\/ul>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"koch-generator.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_207.jpg?resize=151%2C79\" width=\"151\" height=\"79\" class=\"inset right\" \/><\/p>\n<p> You can also draw the generator graphically, as the following:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"square-generator.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_208.jpg?resize=138%2C61\" width=\"138\" height=\"61\" class=\"inset right\" \/><\/p>\n<p> Playing with the rewrite method, you can get some really interesting curves, which<br \/>\noften seem as if they defy the simplicity of their definition. For example,<br \/>\ntake the same initiator as the koch curve, but instead of using a triangle, generate<br \/>\na square: line &rarr; line,left(90),line,right(90),line,right(90),line,left(90),line;<br \/>\nvisually, the replacement for a line is the segment on the right. Now look at what<br \/>\nyou get after 4 and 5 iterations:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"ksquare.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_209.jpg?resize=289%2C443\" width=\"289\" height=\"443\" class=\"inset\" \/><\/p>\n<p> Now, did anyone out there actually <em>expect<\/em>\tthat trivial generator to produce<br \/>\nan intricate cross-lace pattern?<\/p>\n<p> That last one is cheating a bit, because the curve crosses itself; proper curve fractals don&#8217;t do that. But it&#8217;s cool anyway, so I wanted to show it to you. Even staying<br \/>\nwithin the non-crossing curves, there are numerous variations on the Koch curve that<br \/>\nare interesting.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"zig-generator.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_210.jpg?resize=177%2C82\" width=\"177\" height=\"82\" class=\"inset right\" \/><\/p>\n<p> For example, look at this generator: &#8220;line&rarr;line,left(30),line,right(90),line,left(90),line,right(30),line&#8221;, shown graphically to the left. Run it for 4 iterations, and you get a curve like below. Now, that&#8217;s starting to look rather a lot like a coastline, isn&#8217;t it? It&#8217;s <em>still<\/em><br \/>\ncompletely regular, but it&#8217;s really starting to look quite different, and interestingly<br \/>\nreal.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"reg-coast.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_211.jpg?resize=372%2C243\" width=\"372\" height=\"243\" \/><\/p>\n<p> Throw in a little bit of randomness, and the regularity starts to fade out, even though the generation process remains regular. You get bays and inlets, promontories, etc., all of<br \/>\nthe features of a real shoreline. The following two graphs are samples from the same generator as above, but randomly varying the length of the straight lines when a segment<br \/>\nis replaced. The segments that replace the straight are always shorter than the segment they replace, but the ratio of segment length to replacement length is randomized.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"coastlines.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_212.jpg?resize=485%2C205\" width=\"485\" height=\"205\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just finally got my copy of Mandelbrot&#8217;s book on fractals. In his discussion of curve fractals (that is, fractals formed from an unbroken line, isomorphic to the interval (0,1)), he describes them in terms of shorelines rather than borders. I&#8217;ve got to admit that his metaphor is better than mine, and I&#8217;ll adopt it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[86],"tags":[],"class_list":["post-472","post","type-post","status-publish","format-standard","hentry","category-fractals"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-7C","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}