Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics - Lecture 6

Similar presentations


Presentation on theme: "Computer Graphics - Lecture 6"— Presentation transcript:

1 Computer Graphics - Lecture 6
Fractal Graphics Objectives To give a definition and a classification of fractals. To present some other deterministic self-similar fractal curves. To introduce the most ‘important’ fractals: Julia and Mandelbrot. 4/25/2019 Computer Graphics - Lecture 6

2 Computer Graphics - Lecture 6
Fractals A fractal is a set of points such that: - its fractal dimension is infinite [infinite detail at every point]. - satisfies self-similarity: any part of the fractal is similar with the fractal. Generating a fractal is a iterative process: - start from P0 - iteratively generate P1=F(P0), P2=F(P1), …, Pn=F(Pn-1), … P0 is a set of initial points F is a transformation: Geometric transformations: translations, rotations, scaling, … Non-Linear coordinate transformation. 4/25/2019 Computer Graphics - Lecture 6

3 Computer Graphics - Lecture 6
Clasification The nature of F gives: Deterministic Fractals: Stochastic Fractals: F is a random process. The aspect of the fractal set: Self-Similar: parts are scaled down of a fractal pattern. Self-Affine: formed by scaling with different parameters. Non-Linear Fractals: formed by non-linear transformation. The most popular fractals: - Koch’s fractal or Snowflake. - The Julia sets. - The Mandelbrot set. 4/25/2019 Computer Graphics - Lecture 6

4 Computer Graphics - Lecture 6
Koch’s curve 4/25/2019 Computer Graphics - Lecture 6

5 Computer Graphics - Lecture 6
Julia Set 4/25/2019 Computer Graphics - Lecture 6

6 Computer Graphics - Lecture 6
Mandelbrot Set 4/25/2019 Computer Graphics - Lecture 6

7 Deterministic Self-Similar Fractals
Deterministic Self-Similar Fractals = Geometric Fractals. Similarity gives a generator pattern. Based on GP we can find the transformation F. Example:Quadratic Koch’s curve K(1,l) is a line K(n,l)= K(n-1,l/4);right(90);K(n-1,l/4);left(90);K(n-1,l/4);left(90); K(n-1,n/4); K(n-1,n/4);right(90); K(n-1,n/4);right(90); K(n-1,n/4); left(90); K(n-1,n/4) 4/25/2019 Computer Graphics - Lecture 6

8 Quadratic Koch’s Curve
4/25/2019 Computer Graphics - Lecture 6

9 Computer Graphics - Lecture 6
Complex Numbers C the set complex numbers z=a+j*b, a,bR and j2=-1 Operations with Complex Numbers: z1 + z2 = (a1+j*b1) + (a2+j*b2)=(a1 + a2 ) +j*(b1+ b2). z1 * z2 = (a1+j*b1) * (a2+j*b2)=(a1*a2 - b1*b2 ) +j*(a1*b2 + b1*a2 ). | z1 | = sqrt(a12+ b12) b z=a+i*b |z| a 4/25/2019 Computer Graphics - Lecture 6

10 Computer Graphics - Lecture 6
Complex Numbers (2) Complex Numbers in trigonometrically format: z=a+j*b=|z|(cos +j*sin ) z1 * z2 = |z1|(cos1+j*sin1)*|z2|(cos2+j*sin 2)= =|z1* z2 | (cos(1+ 2)+j*sin(1+ 2)) b z=a+i*b |z| a 4/25/2019 Computer Graphics - Lecture 6

11 Computer Graphics - Lecture 6
Complex Class public class Complex{ private double re, im; public Complex(double x0,double y0) {re=x0;im=y0;} public Complex(){re=im=0;} public Complex(Complex z){re=z.re;im=z.im;} public double getRe(){return re;} public double getIm(){return im;} public double getAbs(){return Math.sqrt(re*re+im*im);} public Complex conjugate(){return new Complex(re,-im);} public static Complex sum(Complex z1,Complex z2){ Complex sum = new Complex(); sum.re=z1.re+z2.re;sum.im=z1.im+z2.im; return sum; } public static Complex product(Complex z1,Complex z2){ Complex prod = new Complex(); prod.re=z1.re*z2.re-z1.im*z2.im; prod.im=z1.im*z2.re+z2.im*z1.re; return prod; } public void write() {System.out.println("" + re + " +i* " + im);} public static Complex read(){ Complex z = new Complex(); System.out.print("re = ");z.re=Read.readDouble(); System.out.print("im = ");z.im=Read.readDouble(); return z; 4/25/2019 Computer Graphics - Lecture 6

12 Julia Sets – Self-Squaring Fractals
Consider the generating function F(z)=z2+c, z,c C. Sequence of complex numbers: z0C and zn+1= zn2 + c. Chaotic behaviour but two attractors for |zn|: 0 and +. For a c C, Julia’s set Jc represents all the points whose orbit is finite. 4/25/2019 Computer Graphics - Lecture 6

13 Computer Graphics - Lecture 6
Julia Sets – Algorithm Inputs: c C the complex number; [xmin,xmax] * [ymin,ymax] a region in plane. Niter a number of iterations for orbits; R a threshold for the attractor . Output: Jc the Julia set of c Algorithm For each (x,y) in [xmin,xmax] * [ymin,ymax] construct z0=x+j*y; find the orbit of z0 [first Niter elements] if (all the orbit points are under the threshold) draw (x,y) 4/25/2019 Computer Graphics - Lecture 6

14 Computer Graphics - Lecture 6
public void paint(Graphics g){ g.setColor(Color.red);g.fillRect(10,10,SIZE,SIZE); g.setColor(Color.yellow); for(int i=0;i<SIZE;i++)for(int j=0;j<SIZE;j++){ Complex z = new Complex(XMIN+i*STEP,YMIN+j*STEP); int k; for (k=0;k<NR_ITER;k++){ z=f(z,c); if(z.getAbs()>R)break; } if (k==NR_ITER) g.drawOval (10+i,10+j,1,1); The whole java code is L7Appl1.java and the applet is L7Appl1.html. Some values that give nice fractals: c=-0.83+j*0.16,  c=-0.13+j*0.76, c=-0.39+j*0.58, c=0.785+j*0.13, etc.   4/25/2019 Computer Graphics - Lecture 6

15 Computer Graphics - Lecture 6
                                                  c = 0.275 c = 1/4 c = 0 c = -3/4 c = -1.312 c = -1.375 c = -2 c = i c = (+0.285, +0.535) c = (-0.125, +0.750) c = (-0.500, +0.563) c = (-0.687, +0.312) 4/25/2019 Computer Graphics - Lecture 6

16 Computer Graphics - Lecture 6
4/25/2019 Computer Graphics - Lecture 6

17 Computer Graphics - Lecture 6
4/25/2019 Computer Graphics - Lecture 6

18 Computer Graphics - Lecture 6
Maldelbrot Set Maldelbrot Set contains all the points cC such that z0=0 and zn+1= zn2 + c has an finite orbit. Inputs: [xmin,xmax] * [ymin,ymax] a region in plane. Niter a number of iterations for orbits; R a threshold for the attractor . Output: M the Mandelbrot set. Algorithm For each (x,y) in [xmin,xmax] * [ymin,ymax] c=x+i*y; find the orbit of z0=0 while under the threshold. if (all the orbit points are not under the threshold) draw c(x,y) 4/25/2019 Computer Graphics - Lecture 6

19 Computer Graphics - Lecture 6
public void paint(Graphics g){ g.setColor(Color.blue);g.fillRect(10,10,SIZE,SIZE); for(int i=0;i<SIZE;i++)for(int j=0;j<SIZE;j++){ Complex c = new Complex(XMIN+i*STEP,YMIN+j*STEP); // create a number c Complex z = new Complex(); // create z=0 int k; // find the orbit for (k=0;k<NR_ITER;k++){ z=f(z,c); // the point is above the threshold if(z.getAbs()>R){ g.setColor(col[k%col.length]); g.drawOval(10+i,10+j,1,1); break; } The whole java file L7Appl2.java and the applet is L7Appl2.html. 4/25/2019 Computer Graphics - Lecture 6

20 Computer Graphics - Lecture 6
4/25/2019 Computer Graphics - Lecture 6

21 Computer Graphics - Lecture 6
Problems to Solve 1. Draw the self-similar fractal with the generator 2. Modify the function F(z)=z2+c and find some new fractal sets. F(z)= - z2+c, F(z)=z*(1-z)+c of even F(z)=z3+c. To Read: Peter Cooley, The Essence of Computer Graphics, (Modelling Natural Objects), pp75-93. Some web links: ( 4/25/2019 Computer Graphics - Lecture 6


Download ppt "Computer Graphics - Lecture 6"

Similar presentations


Ads by Google