The classical fractal algorithm

Source: Internet
Author: User
Tags cos sin

Reproduced from: http://www.douban.com/note/230496472/

As a new branch of modern mathematics, the fractal (fractal) theory, known as the geometry of nature, is a new world outlook and methodology. It is combined with the chaos theory of dynamical system and complements each other. It admits that the part of the world may be in certain conditions, in a certain aspect (shape, structure, information, function, time, energy, etc.) to show the similarity with the whole, it admits that the change of space dimension can be either discrete or continuous, thus expanding the field of vision.

The concept of fractal geometry was first proposed by the American French mathematician Mandebro (B.b.mandelbrot) in 1975, but the earliest work could be traced to 1875, and the German mathematician Weierstrass (K.weierestrass) constructed a continuous but ubiquitous function, set on founder Cantor (g.cant Or, a German mathematician) constructs a three-point Cantor set with many singular properties. In the 1890, the Italian mathematician Piano (G.peano) constructed the curve of the filling space. In 1904, the Swedish mathematician Koch (H.von Koch) designed a curve resembling snowflakes and island edges. In the 1915, Polish mathematician Sierpiński (W.sierpinski) designed geometries like carpets and sponges. These are the counter examples to solve the problems in analysis and extension topology, but they are the source of fractal geometry thought. In the 1910, the German mathematician Hausdorf (F.hausdorff) began the study of the nature and quantity of singular sets, and proposed the concept of fractional dimension. The 1928 Bligan (G.bouligand) applied Minkowski to the non-integer dimension, which can be used to classify the helix well. 1932 Pontryagin (L.s.pontryagin) such as the introduction of box dimensions. In the 1934, Besekovic (A.s.besicovitch) More profoundly suggested the nature of the Hausdorf measure and the fractional dimension of the singular set, and he made a major contribution in the field of Hausdorf measurement and its geometry, thus producing the Hausdorf-Besekovicivi number concept. In the future, research in this field has not attracted much attention, and the pioneers ' work has been circulated as a counter example in the textbook of Analysis and Topology.
The real understanding of the fractal is the beginning of the popularity of the computer, and at first, the computer graphics of the fractal graph just stay in the two-dimensional plane, but it is enough to make people fascinated. Recently, a Daniel White (English piano Teacher) has proposed a bold way to create an amazing 3D fractal image and name them Mende balls (mandelbulb).


Under the Mende of the ball, this set is actually derived from a very basic algorithm. That's an algorithm that uses complex numbers. As far as the Mandebro set is concerned, it is directly derived from the simplest of powers-the number of the plural. But the problem is that the concept of numbers cannot be properly extended in three-dimensional space. Unlike the complex peace pastry, mathematicians of the 19th century have proved that points in a stereo space cannot be represented by algebraic tools suitable for traditional addition and multiplication operations. Since it is impossible to define a numerical calculation, it is impossible to sketch the three-dimensional image of a Mandebro set. One solution is to compute in a four-dimensional space and then project the results into three-dimensional space. Each point in the four-dimensional space can be matched to the "four-number" (quaternion) and can be used for traditional arithmetic operations. Although the four-dimensional space can not be seen with the naked eye, but the use of four of dollars will be able to easily list the corresponding to the Mandebro set of algorithms, then remove a component, you can show the results of three-dimensional effect. But the plan is disappointing, and the resulting picture is not much better than the two-dimensional image.
To avoid the problem, Daniel White a strange idea two years ago. Completely free of the shackles of mathematics, he constructed a kind of "pseudo fractal" between points and points in three-dimensional space. Although the method of processing is not the most appropriate multiplication, at least the algorithm corresponding to the Mandebro set is extended to all the points in the three-dimensional space. Daniel White Millions of points to calculate, and then added light and texture to reflect the stereo effect, finally, on his screen presents the first Mende ball, shape and strict Mandebro set very approximate. Sadly, the result failed to satisfy his expectations: "The graphics are amazing, but I expect finer details." ”
The attempt did not stop there. Daniel White A young American computer expert, Paul Nilander, in a forum on the Internet. He took over Wright's research and made a few changes to the algorithm, replacing the repeated squared operation with the higher side (eight), thus getting a series of new Mende balls, the higher the index, the richer the details.
This Mende ball aroused my great interest, determined to learn the form of credits, so decided to learn from the simplest fractal algorithm, I hope to share with you.

Here are some examples of the simplest fractal algorithms:
Recursive algorithm of first and cantor three-diversity
Select a Euclidean length line segment, divide the segment into three halves, remove the middle section, and leave two paragraphs. Divide the remaining two paragraphs repeatedly, each minus the middle section and four paragraphs. To continue this operation until infinity, you can get a discrete set of points. The points tend to be infinitely many, while the Euclidean lengths tend to zero. The discrete point set obtained when the limit is reached by infinite operation is called Cantor set.
1. Given the coordinates of the initial line two endpoints (Ax,ay) and (Bx,by), the coordinates of a key point are calculated according to the generation rules of the Cantor three-part set:
cx=ax+ (BX-AX)/3
Cy=ay-d
dx=bx-(BX-AX)/3
Dy=by-d
Ay=ay-d
By=by-d
2. Using the recursive algorithm, the computed new points are respectively corresponding to (Ax,ay) and (Bx,by), and then the next-level new Point (Cx,cy) and (Dx,dy) are computed and pressed into the stack using the computational relationship of Step 1.
3. Given a small amount of C, when (Bx,by) <c, the values in the stack are released sequentially, drawing straight lines (Ax,ay)-(Bx,by), and then the program ends.
The following MATLAB program:
function F=cantor (ax,ay,bx,by)
c=0.005;d=0.005;
if (Bx-ax) >c
X=[ax,bx];y=[ay,by];hold on;
Plot (x,y, ' linewidth ', 2); hold off;
cx=ax+ (Bx-ax)/3;
cy=ay-d;
dx=bx-(Bx-ax)/3;
dy=by-d;
ay=ay-d;
by=by-d;
Cantor (AX,AY,CX,CY);
Cantor (Dx,dy,bx,by);
End
Run Cantor (0,5,5,5), the following legend appears:

Recursive algorithm of Koch curve
On a unit length line segment, the middle segment is replaced by a equilateral that removes the bottom edge, and then repeats the above operation on each line, so that the fractal curve Koch curve is obtained until infinity.
1. Given the initial line (Ax,ay)-(Bx,by), according to the composition of the Koch curve to calculate the coordinates of the key points are as follows:
cx=ax+ (BX-AX)/3
cy=ay+ (By-ay)/3
ex=bx-(BX-AX)/3
ey=by-(By-ay)/3
L=sqrt ((EX-CX) ^2+ (ey-cy) ^2)
Alpha=atan ((ey-cy)/(EX-CX))
Dy=cy+sin (ALPHA+PI/3) *l
Dx=cx+cos (ALPHA+PI/3) *l
2. Using the recursive algorithm, the computed new points are respectively corresponding to (Ax,ay) and (Bx,by), and then the next level new Point (Cx,cy), (Dx,dy), (Ex,ey) is computed using the calculation formula in step 1, and is pressed into the stack.
3. Given a small amount of C, when L<c, the values in the stack are released sequentially, drawing straight lines (Ax,ay)-(Bx,by), and then ending the program.
The following MATLAB program:
function F=koch (ax,ay,bx,by,c)
if (bx-ax) ^2+ (By-ay) ^2<c
X=[ax,bx];y=[ay,by];
Plot (x,y); hold on;
Else
cx=ax+ (Bx-ax)/3; cy=ay+ (By-ay)/3;
ex=bx-(Bx-ax)/3; ey=by-(By-ay)/3;
L=sqrt ((EX-CX) ^2+ (ey-cy) ^2);
Alpha=atan ((ey-cy)/(EX-CX));
if (alpha>=0& (EX-CX) <0) | (alpha<=0& (EX-CX) <0)
Alpha=alpha+pi;
End
Dy=cy+sin (ALPHA+PI/3) *l;
Dx=cx+cos (ALPHA+PI/3) *l;
Koch (AX,AY,CX,CY,C);
Koch (EX,EY,BX,BY,C);
Koch (CX,CY,DX,DY,C);
Koch (DX,DY,EX,EY,C);
End
Run Koch (0,0,100,0,10), the following legend appears:

Third, generate fill Julia set
1. Set parameter a,b and a maximum number of iterations N.
2. Set a threshold R, that is real R≧max (2,sqrt (a^2+b^2).
3. For each point in the plane with R as the radius of the disk iteration, if for all n≦n, there is |x^2+y^2|≦r, then, on the screen to draw the corresponding starting point, otherwise do not draw.
The following MATLAB program:
a=-0.11;b=0.65;r=2;
For X0=-1:0.01:1
For Y0=-1:0.01:1
X=x0;y=y0;
If x0^2+y0^2<1
For n=1:80
X1=x*x-y*y+a;
Y1=2*x*y+b;
x=x1;
Y=y1;
End
if (x*x+y*y) <r
Plot (X0,Y0);
End
Hold on;
End
End
End
a=-0.11,b=0.65

a=-0.13,b=0.77

a=-0.19,b=0.6557



Iv. Newton Iteration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.