Fractal

A fractal is a shape that is geometrically "infinitely complex" while being described in a simple algorithm. They are formed by iteratively and recursively (repeatedly) applying its defining rule. When zoomed into a fractal, we see the shapes within retain the shape of the whole - fractal shapes can be found in nature. A perfect fractal is a theoretical fractal with the rule applied infinitely many times.

                                                    V   V V   V    
                                \ /   \ /         V  \ /   \ /  V  
               |     |      _|   |     |   |_   >_|   |     |   |_<
            '-.|     |.-'     '-.|     |.-'        '-.|     |.-'   
   \   /        \   /             \   /                \   /       
    \ /          \ /               \ /                  \ /        
     |            |                 |                    |         
     |            |                 |                    |         
     |            |                 |                    |         

iteration 0  iteration 1       iteration 2          iteration 3    

                                Branching                               

        Rule: On each branch, grow two smaller branches
                                    /\       
                                   /\/\      
                                  /\  /\     
                                 /\/\/\/\    
                   /\           /\      /\   
                  /\/\         /\/\    /\/\  
        /\       /\  /\       /\  /\  /\  /\ 
/\ --> /\/\ --> /\/\/\/\ --> /\/\/\/\/\/\/\/\
It1    It 2       It 3             It 4      
       
             Sierpinski Triangle             
 ___________________________________________________________
|[-2,1]                                       .             |
|                                            .:.            |
|                                           :::::           |
|                                         ...:::..  .       |
|                                    :..:::::::::::::....   |
|                                   .:::::::::::::::::::'   |
|                                 ::::::::::::::::::::::::  |
|                                :::::::::::::::::::::::::' |
|                     :..:::.   .:::::::::::::::::::::::::: |
|                   .:::::::::. ::::::::::::::::::::::::::  |
|                .. ::::::::::: :::::::::::::::::::::::::'  |
|      '  '     '::':::::::::::'::::::::::::::::::::::::.   |
|                   ::::::::::: ::::::::::::::::::::::::::  |
|                    ':::::::'  ::::::::::::::::::::::::::. |
|                     '  '''     :::::::::::::::::::::::::' |
|                                '::::::::::::::::::::::::' |
|                                 ''::::::::::::::::::::''  |
|                                    ::::::::::::::::::::   |
|                                    '  ''::::::::'':       |
|                                           .:::.           |
|                                           ':::'           |
|                                             :             |
|___________________________________________________[0.5,-1]|

                         Mandelbrot Set                      
 ___________________________________________________________________
| Julia Set for -0.34 - 0.63i       :.                              |
|                                ..':. ..                           |
|                                '':.:'''      ..       ..          |
|                                 :':::.. ''  ::.    .. :.'         |
|                                  '::::. :: :::. .   :.'': .       |
|                              ......':::.::.:: ...::.:::.::.. .    |
|                              :::::::::':'.':.::::::::':.::''::..  |
|                   .             '::::'':':::':'':::'  ::''  '     |
|                   ':.       .   .. ..::'::':::.   '   :'          |
|                 . :: :'     ::..::::::: ::: ':::..     '          |
|                   :'::::   '.:::::::::'.::::'  ''                 |
|                    .:::::' ':::::::::. ''::::'.                   |
|                  :. '::::'.::::::::::.  '::':.'                   |
|          . .   '':::. ::: ::::::::'::'    .::::                   |
|         :':.  ... ':::.:':::''  '  '        ''.                   |
|        ..::  .::::::...':.::::::.:                                |
|   :::...' '.::::::::'.: .:.:'::::'':                              |
|    '' :. : .:''':' :::'::':::.   ' '                              |
|         '::'': '' '::: ::'':::::                                  |
|          ::       ':.  '' '':::.:                                 |
|         ' '       '        ::.:.'.'                               |
|                              ::'                                  |
|                              '                                    |
|___________________________________________________________________|

                            Julia Set                               

C implementations: Mandelbrot set, Julia set


Fractal curve

Based on some shape, which is rotated at a specific angle for an iteration.

.     _.   _      _       _
|    |    | |_.  | |_    | |_
                    _|      _|
                   |_.    _|_
                        _| |_|
                       |_.
0    1    2      3      4
   Dragon Curve

Video of Dragon Curve (17 iterations)

Algorithm, Iteration and recursion