Fractals
From GenerativeArt
(Difference between revisions)
Current revision (22:33, 16 September 2013) (view source) (→Fractal or Box Counting Dimension) |
|||
- | + | ===Self-similarity=== | |
- | + | ||
Fractals are structures that exhibit self-similarity at all scales. Such self-similarity may be: | Fractals are structures that exhibit self-similarity at all scales. Such self-similarity may be: | ||
* Exact. (Typically systems which are created by an iterative recursive function). | * Exact. (Typically systems which are created by an iterative recursive function). | ||
* Quasi-self-similar. (Typically where micro-structures are distorted versions of the macro-structure). | * Quasi-self-similar. (Typically where micro-structures are distorted versions of the macro-structure). | ||
- | * | + | * Statistical. (Where an empirical measure remains constant across scales). |
- | + | {| | |
+ | |- | ||
+ | |{{SingleImage|imageWidthPlusTen=410|imageURL=http://philipgalanter.com/generative_art/graphics/fractalANI.gif|caption=Zoom-in on Koch fractal}} | ||
+ | |{{SingleImage|imageWidthPlusTen=410|imageURL=http://philipgalanter.com/generative_art/graphics/nonfractalANI.gif|caption=Zoom-in on non-fractal curve}} | ||
+ | |} | ||
+ | ===Occurrences of fractals=== | ||
Taken loosely, fractals can occur in a number of ways. For example: | Taken loosely, fractals can occur in a number of ways. For example: | ||
* Some mathematical functions define sets of points where the boundry between in-set and out-of-set points exhibit self-similarity across scales. e.g. The Julia set, the Mandelbrot set, and others. | * Some mathematical functions define sets of points where the boundry between in-set and out-of-set points exhibit self-similarity across scales. e.g. The Julia set, the Mandelbrot set, and others. | ||
* In chaotic systems a phase diagram will exhibit fractal behavior about a strange attractor. (To be covered later). | * In chaotic systems a phase diagram will exhibit fractal behavior about a strange attractor. (To be covered later). | ||
+ | |||
+ | ===Fractals as recursive functions=== | ||
+ | Fractals can be defined and generated by recursive functions. For example, take the factorial function: | ||
+ | :<var>5! = 5 * 4 * 3 * 2 * 1</var> | ||
+ | :<var>N! = N * (N - 1) * (N - 2) * ... * 1</var> | ||
+ | |||
+ | =====Non-recursive factorial function===== | ||
+ | '''function''' FACTORIAL(m) | ||
+ | total = 1 | ||
+ | '''for''' n = 1 to m | ||
+ | total = total * m | ||
+ | '''end''' | ||
+ | '''return''' total | ||
+ | |||
+ | =====Recursive factorial function===== | ||
+ | '''function''' FACTORIAL(m) | ||
+ | '''if''' m > 1 | ||
+ | '''return''' m = m * FACTORIAL(m-1) | ||
+ | '''else''' | ||
+ | '''return''' 1 | ||
+ | '''end''' | ||
+ | |||
+ | =====Recursive Koch curve===== | ||
+ | {{SingleImage|imageWidthPlusTen=410|imageURL=http://philipgalanter.com/generative_art/graphics/kochcurveprogression.gif|caption=The recursion of a Koch curve}} | ||
+ | // Given: | ||
+ | // res :length of smallest line to be drawn | ||
+ | // DRAW(x1, y1, x2, y2) :draws a point from (x1, y1) to (x2, y2) | ||
+ | // DIST(x1, y1, x2, y2) :distance between points (x1, y1) and (x2, y2) | ||
+ | // BEND(x1, y1, x2, y2) :takes one line segment and bends it into 4 returning tx1, ty,2, tx2, ..., ty5 | ||
+ | <br> | ||
+ | '''function''' KOCH(x1, y1, x2, y2, res) | ||
+ | '''if''' DIST(x1, y1, x2, y2) < res | ||
+ | DRAW(x1, y1, x2, y2) | ||
+ | '''else''' | ||
+ | BEND(x1,y1,x2,y2) | ||
+ | KOCH(tx1, ty1, tx2, ty2, res) | ||
+ | KOCH(tx2, ty2, tx3, ty3, res) | ||
+ | KOCH(tx3, ty3, tx4, ty4, res) | ||
+ | KOCH(tx4, ty4, tx5, ty5, res) | ||
+ | '''endif''' | ||
+ | <br> | ||
+ | |||
+ | =====Stochastic fractal river===== | ||
+ | Both fractals and L-systems can have stochastic (random/chance) forms. | ||
+ | // Given: | ||
+ | // res :length of smallest line to be drawn | ||
+ | // DIST(x1, y1, x2, y2) :distance between points (x1, y1) and (x2, y2) | ||
+ | // BEND(x1, y1, x2, y2) :returns x3,y3 randomly between and offset | ||
+ | <br> | ||
+ | '''function''' RIVERBEND(x1, y1, x2, y2, res) | ||
+ | '''if''' DIST(x1, y1, x2, y2) > res | ||
+ | BEND(x1, y1, x2, y2) | ||
+ | RIVERBEND(x1, y1, x3, y3) | ||
+ | RIVERBEND(x3, y3, x2, y2) | ||
+ | '''else''' | ||
+ | DRAW(x1, y1, x2, y2) | ||
+ | '''endif''' | ||
+ | <br> | ||
+ | |||
+ | ===Fractal or Box Counting Dimension=== | ||
+ | <br /> | ||
+ | In traditional units a Koch curve will have infinite length but 0 area. This is not a useful measurement.<br /> | ||
+ | A measurement of dimension filling. For example, D = 1.4 means it fills more than a line, but less than a plane.<br /> | ||
+ | <br /> | ||
+ | Where epsilon is the relative size of the division (1, 1/2, 1/3, etc.), and N is the number of copies or boxes.<br /> | ||
+ | Using this formula for increasingly smaller divisions, if the object is a fractal the dimension will be about the same.<br /> | ||
+ | If the dimension changes with scale the object is not a fractal.<br /> | ||
+ | <br /> | ||
+ | {{SingleImage|imageWidthPlusTen=510|imageURL=http://philipgalanter.com/generative_art/graphics/box_counting_formula.png|caption=}}<br /> | ||
+ | {{SingleImage|imageWidthPlusTen=510|imageURL=http://www.viz.tamu.edu/courses/viza626/10Fall/fractImg1.gif|caption=Cantor dust breaks the segment in thirds and discards the middle one}}<br /> | ||
+ | {{SingleImage|imageWidthPlusTen=510|imageURL=http://www.viz.tamu.edu/courses/viza626/10Fall/fractImg2.gif|caption=Koch curve breaks the segment into 4 segments}}<br /> | ||
+ | {{SingleImage|imageWidthPlusTen=510|imageURL=http://www.viz.tamu.edu/courses/viza626/10Fall/fractImg3.gif|caption=Note that a line segment has a fractal dimension of 1}}<br /> | ||
+ | {{SingleImage|imageWidthPlusTen=510|imageURL=http://www.viz.tamu.edu/courses/viza626/10Fall/fractImg4.gif|caption=Note that a square has a fractal dimension of 2}}<br /> | ||
+ | {{SingleImage|imageWidthPlusTen=600|imageURL=http://philipgalanter.com/generative_art/graphics/sierp-det.GIF|caption=The Sierpinski triangle is constructed yielding 3 copies at 1/2 size so the fractal dimension = log(3)/log(2) = 1.58}}<br />{{SingleImage|imageWidthPlusTen=1000|imageURL=http://philipgalanter.com/generative_art/graphics/box_counting_dimension.png|caption=Here is an illustration of the box counting method to measure the fractal dimension of actual objects, in this case the coastline of England}}<br /> |