Difference between revisions of "Approaches"
From Techniques for computer generated pictures in complex dynamics
m (→Scanline and direct) |
(→Backward and forward iteration) |
||
Line 16: | Line 16: | ||
Backward iteration means that $z_2=f^{-1}(z_1)$, etc... The solution may be non-unique. | Backward iteration means that $z_2=f^{-1}(z_1)$, etc... The solution may be non-unique. | ||
− | In the | + | In the scanline approach, I nearly always used forward iteration. |
− | + | === Example of scanline algorithm with forward iteration === | |
+ | |||
+ | A famous example is the following, one of the first methods used to draw Mandelbrot's set: | ||
+ | |||
+ | * Choose a maximal number of iterations N (integer), a scaling factor a (real or complex) and an offset b (complex number) | ||
+ | * For all pixel in the image, whose coordinate we call (i,j): | ||
+ | ** Compute the complex number c from (i,j)<br/>typically set c=a×(i-j×√-1)+b (there are nicer formulas) | ||
+ | ** Set the complex number z=0 | ||
+ | ** Do the following at most N times: | ||
+ | *** if the module of z is bigger that 4: | ||
+ | **** color the pixel (i,j) white | ||
+ | **** exit the loop and pass to the next pixel | ||
+ | *** (otherwise) compute z<sup>2</sup>+c and let z be this quantity | ||
+ | *** carry on the loop | ||
+ | ** If the loop ends without having given a white pixel, set it to black | ||
+ | ** pass to the next pixel | ||
+ | |||
+ | The bigger N, the better image, but the computation time increases with N. | ||
+ | |||
+ | There are better algorithms, see the special page [[Mandelbrot set]] on this wiki. | ||
+ | |||
+ | {{expand}} |
Revision as of 12:54, 20 April 2014
Scanline and direct
When creating an image there are two main methods:
- scanline methods: all pixels in the image will be scanned. For each pixel, the color has to be determined. The coordinates of the pixel are converted into mathematical parameters. Then an algorithm is run on that parameter. For instance we may have a dynamical system, the point may represent a point in phase space, whose orbit we simulate/iterate, and the color of the pixel will be chosen according to the behaviour of the orbit.
- direct drawing: points, lines or areas, are determined by their mathematical coordinates, converted into pixel coordinates, and drawn
A vast majority of my images use scanline algorithms.
Backward and forward iteration
This concerns discrete dynamical systems.
Forward iteration means that we compute z1, z2=f(z1), z3=f(z2), etc... Backward iteration means that $z_2=f^{-1}(z_1)$, etc... The solution may be non-unique.
In the scanline approach, I nearly always used forward iteration.
Example of scanline algorithm with forward iteration
A famous example is the following, one of the first methods used to draw Mandelbrot's set:
- Choose a maximal number of iterations N (integer), a scaling factor a (real or complex) and an offset b (complex number)
- For all pixel in the image, whose coordinate we call (i,j):
- Compute the complex number c from (i,j)
typically set c=a×(i-j×√-1)+b (there are nicer formulas) - Set the complex number z=0
- Do the following at most N times:
- if the module of z is bigger that 4:
- color the pixel (i,j) white
- exit the loop and pass to the next pixel
- (otherwise) compute z2+c and let z be this quantity
- carry on the loop
- if the module of z is bigger that 4:
- If the loop ends without having given a white pixel, set it to black
- pass to the next pixel
- Compute the complex number c from (i,j)
The bigger N, the better image, but the computation time increases with N.
There are better algorithms, see the special page Mandelbrot set on this wiki.