Fractal Slide Set 9 05 Fractals Fractals have

  • Slides: 15
Download presentation
Fractal Slide Set 9. 05

Fractal Slide Set 9. 05

Fractals • Fractals have many uses in graphics • Ordered randomness • Fractals are

Fractals • Fractals have many uses in graphics • Ordered randomness • Fractals are self similar on different scales, much like real objects • The veins on a leaf resemble the branching structure of a tree • A small part of a coastline looks similar to a longer part at larger scale • One of many approaches to defining fractals makes this notion more rigorous and precise • Fractals can be very interesting to look at, this is what this example is about 2

Dynamical Systems • Two parts • A space S • A function taking members

Dynamical Systems • Two parts • A space S • A function taking members of S as input and producing members of S as output • We are interested in iterated sequences • x, f(x), f(f(x)), f(f(f(x))), … • That is, what happens to a value in the space S when the function is applied to it and then applied to that result 3

cosine • Dynamical system • Real numbers form the space • The cosine is

cosine • Dynamical system • Real numbers form the space • The cosine is the function (angles in radians) • Demonstrate in a calculator • Whatever the starting value, the sequence converges to a particular value • The limit is a fixed point of the cosine 4

This Example • 5

This Example • 5

Image • Next slide shows a picture of part of the complex plane •

Image • Next slide shows a picture of part of the complex plane • Notice the complexity • We will see that zooming in on smaller areas shows similar patterns to the large scale pattern shown here 6

7

7

Driver Code • Scene is a single square • No transformations • Square covering

Driver Code • Scene is a single square • No transformations • Square covering the default clipping volume. The only vertex data used is the positions of the corners of the square. • Rectangular part of complex plane displayed • Specified by • Center point • Width and height of the area. • More convenient to store half the width and the height. 8

User Interaction • W moves towards the fractal, magnifying small features • S moves

User Interaction • W moves towards the fractal, magnifying small features • S moves away, showing large scale features • Arrow keys shift the viewing rectangle around 9

Representing Complex Numbers • The shaders use vec 2 to represent complex numbers •

Representing Complex Numbers • The shaders use vec 2 to represent complex numbers • v. x is the real part, v. y is the imaginary part • Fragment shader has functions defined to provide multipilication and 10

Vertex Shader • Uses the vertex position and the display area parameters to compute

Vertex Shader • Uses the vertex position and the display area parameters to compute a complex number corresponding to that vertex position • v. Pos = b. Position. xy * range + center • This is sent to the fragment shader • Because of interpolation, the value of v. Pos received in the fragment shader corresponds to the complex number at the fragment position 11

Fragment Shader • Defines functions to carry out arithmetic operations for complex numbers represented

Fragment Shader • Defines functions to carry out arithmetic operations for complex numbers represented by vec 2 • Defines the three convergents • Defines how close an iterate has to be to a convergent to consider it the ultimate limit • Gets a value that limits the number of iterations to take in the main computation • Gets a list of colors and the number of colors actually available • The number provided must fit into the array defined • The precision used for floats is set higher than usual 12

Fragment Shader Main Loop • A for loop that is limited in number of

Fragment Shader Main Loop • A for loop that is limited in number of iterations • The variable z is initialized with the start value • If z is close to a convergent • The color is set • The loop is exited • Otherwise, compute the next iterate 13

Run • Navigate • Note that we eventually run into a lack of precision

Run • Navigate • Note that we eventually run into a lack of precision in the computations 14

Alternate Display Color • An interesting variation is to color the fragment according to

Alternate Display Color • An interesting variation is to color the fragment according to how many iterations it took to get close to the convergent • There is much more detail in areas that are solid colored under the previous coloring scheme • Run 15