CS 4731/543: Computer Graphics Lecture 2 (Part II):...
-
Upload
trinhtuyen -
Category
Documents
-
view
223 -
download
2
Transcript of CS 4731/543: Computer Graphics Lecture 2 (Part II):...
![Page 1: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/1.jpg)
CS 4731/543: Computer GraphicsLecture 2 (Part II): Fractals
Emmanuel Agu
![Page 2: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/2.jpg)
What are Fractals?
n Mathematical expressionsn Approach infinity in organized wayn Utilizes recursion on computersn Popularized by Benoit Mandelbrot (Yale university)n Dimensional:
n Line is one-dimensionaln Plane is two-dimensional
n Defined in terms of self-similarity
![Page 3: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/3.jpg)
Fractals: Self-similarity
n Level of detail remains the same as we zoom inn Example: surface roughness or profile same as we zoom inn Types:
n Exactly self-similarn Statistically self-similar
![Page 4: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/4.jpg)
Examples of Fractals
n Cloudsn Grassn Firen Modeling mountains (terrain)n Coastlinen Branches of a treen Surface of a spongen Cracks in the pavementn Designing antennae (www.fractenna.com)
![Page 5: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/5.jpg)
Example: Mandelbrot Set
![Page 6: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/6.jpg)
Example: Mandelbrot Set
![Page 7: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/7.jpg)
Example: Fractal Terrain
Courtesy: Mountain 3D Fractal Terrain software
![Page 8: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/8.jpg)
Example: Fractal Terrain
![Page 9: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/9.jpg)
Example: Fractal Art
Courtesy: Internet Fractal Art Contest
![Page 10: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/10.jpg)
Application: Fractal Art
Courtesy: Internet Fractal Art Contest
![Page 11: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/11.jpg)
Iterated Function Systems (IFS)
n Recursively call a functionn Does result converge to an image? What image?n IFS’s converge to an imagen Examples:
n The Fernn The Mandelbrot set
![Page 12: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/12.jpg)
The Fern
![Page 13: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/13.jpg)
Mandelbrot Set
n Based on iteration theoryn Function of interest:
n Sequence of values (or orbit):
cszf += 2)()(
ccccsd
cccsd
ccsd
csd
++++=
+++=
++=
+=
22224
2223
222
21
))))((((
)))(((
))((
)(
![Page 14: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/14.jpg)
Mandelbrot Set
n Orbit depends on s and cn Basic question,:
n For given s and c,• does function stay finite? (within Mandelbrot set) • explode to infinity? (outside Mandelbrot set)
n Definition: if |d| < 1, orbit is finite else inifiniten Examples orbits:
n s = 0, c = -1, orbit = 0,-1,0,-1,0,-1,0,-1,…..finiten s = 0, c = 1, orbit = 0,1,2,5,26,677…… explodes
![Page 15: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/15.jpg)
Mandelbrot Set
n Mandelbrot set: use complex numbers for c and sn Always set s = 0n Choose c as a complex numbern For example:
• s = 0, c = 0.2 + 0.5i
n Hence, orbit:• 0, c, c2+ c, (c2+ c)2 + c, ………
n Definition: Mandelbrot set includes all finite orbit c
![Page 16: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/16.jpg)
Mandelbrot Set
n Some complex number math:
n For example:
n Modulus of a complex number, z = ai + b:
n Squaring a complex number:
1* −=ii
63*2 −=ii
22 baz +=
ixyyxyix )2()( 22 +−=+
Im
Re
Argand
diagram
![Page 17: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/17.jpg)
Mandelbrot Set
n Calculate first 4 terms n with s=2, c=-1n with s = 0, c = -2+i
![Page 18: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/18.jpg)
Mandelbrot Set
n Calculate first 3 terms n with s=2, c=-1, terms are
n with s = 0, c = -2+i
6318
813
312
2
2
2
=−
=−
=−
( ) iii
iii
ii
510)2(31
31)2()2(
2)2(0
2
2
−−=+−+−
−=+−++−
+−=+−+
![Page 19: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/19.jpg)
Mandelbrot Set
n Fixed points: Some complex numbers converge to certain values after x iterations.
n Example:n s = 0, c = -0.2 + 0.5i converges to –0.249227 + 0.333677i
after 80 iterationsn Experiment: square –0.249227 + 0.333677i and add
-0.2 + 0.5i
n Mandelbrot set depends on the fact the convergence of certain complex numbers
![Page 20: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/20.jpg)
Mandelbrot Set
n Routine to draw Mandelbrot set:n Cannot iterate forever: our program will hang!n Instead iterate 100 timesn Math theorem:
n if number hasn’t exceeded 2 after 100 iterations, never will!
n Routine returns:n Number of times iterated before modulus exceeds 2, orn 100, if modulus doesn’t exceed 2 after 100 iterationsn See dwell( ) function in Hill (figure 9.49, pg. 510)
![Page 21: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/21.jpg)
Mandelbrot dwell( ) function (pg. 510)
int dwell(double cx, double cy){ // return true dwell or Num, whichever is smaller
#define Num 100 // increase this for better pics
double tmp, dx = cx, dy = cy, fsq = cx*cx + cy*cy;for(int count = 0;count <= Num && fsq <= 4; count++){
tmp = dx; // save old real partdx = dx*dx – dy*dy + cx; // new real partdy = 2.0 * tmp * dy + cy; // new imag. Partfsq = dx*dx + dy*dy;
}return count; // number of iterations used
}
![Page 22: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/22.jpg)
Mandelbrot Set
n Map real part to x-axisn Map imaginary part to y-axisn Set world window to range of complex numbers to
investigate. E.g:n X in range [-2.25: 0.75]n Y in range [-1.5: 1.5]
n Choose your viewport. E.g:n Viewport = [V.L, V.R, V.B, V.T]= [60,380,80,240]
n Do window-to-viewport mapping
![Page 23: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/23.jpg)
Mandelbrot Set
![Page 24: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/24.jpg)
Mandelbrot Set
n So, for each pixel:n Compute corresponding point in worldn Call your dwell( ) functionn Assign color <Red,Green,Blue> based on dwell( ) return
valuen Choice of color determines how prettyn Color assignment:
n Basic: In set (i.e. dwell( ) = 100), color = black, else color =white
n Discrete: Ranges of return values map to same color• E.g 0 – 20 iterations = color 1• 20 – 40 iterations = color 2, etc.
n Continuous: Use a function
![Page 25: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/25.jpg)
Mandelbrot Set
Use continuous function
![Page 26: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/26.jpg)
FREE SOFTWARE
n Free fractal generating softwaren Fractintn Fractal Zoomern Fractal Studio
![Page 27: CS 4731/543: Computer Graphics Lecture 2 (Part II): Fractalsweb.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture2_p2.pdf · What are Fractals? n Mathematical expressions n Approach](https://reader033.fdocuments.in/reader033/viewer/2022051105/5aa8370f7f8b9a9a188b4870/html5/thumbnails/27.jpg)
References
n Hill, Appendix 4