I'm working hard to be someone I'll be proud of.
--Your friends at LectureNotes

Note for Computer Graphics - CG by Ravi Shankar

  • Computer Graphics - CG
  • Note
  • Computer Science Engineering
  • B.Tech
  • Uploaded 1 year ago
Ravi Shankar
Ravi Shankar
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

2|Page Sample code for additive fractal: Def fractal(x,y,size, depth) { Drawcross(x,y,size); If (depth>1) { Fractal(y+size, y, size/2, depth-1); Fractal(x-size, y, size/2, depth-1); Fractal(x, y+size, size/2, depth-1); Fractal(x, y-size, size/2, depth-1); } } Sample code for replacement fractal: Def fractal(x, y, size, depth) { If (depth<=1) { Drawtriangle(x, y, size); } else Fractal(x, y, size/2, depth-1); Fractal(x-size/2, y-size*√3, size/2, depth-1); Fractal(x+size/2, y-size*√3, size/2, depth-1); } } Creating an Image By Means of Iterative Function Systems Another way to approach infinity is to apply a transformation to a picture again and again and examine the results. This technique also provides an another method to create fractal shapes An Experimental Copier We take an initial image I0 and put it through a special photocopier that produces a new image I1. I1 is not a copy of I0 rather it is a superposition of several reduced versions of I0. We then take I1 and feed it back into the copier again, to produce image I2. This process is repeated, obtaining a sequence of images I0, I1, I2… called the orbit of I0. Making new copies from old In general this copier will have N lenses, each of which perform an affine mapping and then adds its image to the output. The collection of the N affine transformations is called an “iterated function system”. An iterated function system is a collection of N affine transformations Ti, for i=1,2,…N.

Text from page-3

3|Page Underlying Theory of the Copying Process Each lens in the copier builds an image by transforming every point in the input image and drawing it on the output image. A black and white image I can be described simply as the set of its black points: I = set of all black points = { (x,y) such that (x,y) is colored black } I is the input image to the copier. Then the ith lens characterized by transformation Ti, builds a new set of points we denote as Ti(I) and adds them to the image being produced at the current iteration. Each added set Ti(I) is the set of all transformed points I: Ti(I) = { (x’,y’) such that (x’,y’) = Ti(P) for some point P in I } Upon superposing the three transformed images, we obtain the output image as the union of the outputs from the three lenses: Output image = T1(I) U T2(I) U T3(I) The overall mapping from input image to output image as W(.). It maps one set of points – one image – into another and is given by: W(.)=T1(.) U T2(.) U T3(.) For instance the copy of the first image I0 is the set W (I0). Each affine map reduces the size of its image at least slightly, the orbit converge to a unique image called the attractor of the IFS. We denote the attractor by the set A, some of its important properties are: 1. The attractor set A is a fixed point of the mapping W(.), which we write as W(A)=A. That is putting A through the copier again produces exactly the same image A. The iterates have already converged to the set A, so iterating once more makes no difference. 2. Starting with any input image B and iterating the copying process enough times, we find that the orbit of images always converges to the same A. If Ik = W (k) (B) is the kth iterate of image B, then as k goes to infinity Ik becomes indistinguishable from the attractor A. Drawbacks • Inefficient • Huge amount of memory is required. THE MANDELBROT SET Graphics provides a powerful tool for studying a fascinating collection of sets that are the most complicated objects in mathematics. Julia and Mandelbrot sets arise from a branch of analysis known as iteration theory, which asks what happens when one iterates a function endlessly. Mandelbrot used computer graphics to perform experiments. Mandelbrot Sets and Iterated Function Systems A view of the Mandelbrot set is shown in the below figure. It is the black inner portion, which appears to consist of a cardoid along with a number of wartlike circles glued to it.

Text from page-4

4|Page The IFS uses the simple function f(z) = z2 + c -------------------------------(1) where c is some constant. The system produces each output by squaring its input and adding c. We assume that the process begins with the starting value s, so the system generates the sequence of values or orbit d1= (s)2 + c d2= ((s)2 + c)2 + c d3= (((s)2 + c)2 + c)2 + c d4= ((((s)2 + c)2 + c)2 + c)2 + c ------------------------------(2) The orbit depends on two ingredients the starting point s the given value of c Given two values of s and c how do points dk along the orbit behaves as k gets larger and larger. Specifically, does the orbit remain finite or explode. Orbits that remain finite lie in their corresponding Julia or Mandelbrot set, whereas those that explode lie outside the set. When s and c are chosen to be complex numbers , complex arithmetic is used each time the function is applied. The Mandelbrot and Julia sets live in the complex plane – plane of complex numbers. The IFS works well with both complex and real numbers. Both s and c are complex numbers and at each iteration we square the previous result and add c. Squaring a complex number z = x + yi yields the new complex number: ( x + yi)2 = (x2 – y2) + (2xy)i ----------------------------------(3) having real part equal to x2 – y2 and imaginary part equal to 2xy. Defining the Mandelbrot Set The Mandelbrot set considers different values of c, always using the starting point s =0. For each value of c, the set reports on the nature of the orbit of 0, whose first few values are as follows: orbit of 0: 0, c, c2+c, (c2+c)2+c, ((c2+c)2+c)2 +c,…….. Definition: The Mandelbrot set M is the set of all complex numbers c that produce a finite orbit of 0. If c is chosen outside of M, the resulting orbit explodes. If c is chosen just

Text from page-5

5|Page beyond the border of M, the orbit usually thrashes around the plane and goes to infinity. If the value of c is chosen inside M, the orbit can do a variety of things. For some c‟s it goes immediately to a fixed point or spirals into such a point. JULIA SETS Like the Mandelbrot set, Julia sets are extremely complicated sets of points in the complex plane. There is a different Julia set, denoted Jc for each value of c. A closely related variation is the filled-in Julia set, denoted by Jc, which is easier to define. The Filled-In Julia Set Jc In the IFS we set c to some fixed chosen value and examine what happens for different starting point s. We ask how the orbit of starting point s behaves. Either it explodes or it doesn‟t. If it is finite , we say the starting point s is in Kc, otherwise s lies outside of Kc. Definition: The filled-in Julia set at c, Kc, is the set of all starting points whose orbits are finite. When studying Kc, one chooses a single value for c and considers different starting points. Kc should be always symmetrical about the origin, since the orbits of s and –s become identical after one iteration. Drawing Filled-in Julia Sets A starting point s is in Kc, depending on whether its orbit is finite or explodes, the process of drawing a filled-in Julia set is almost similar to Mandelbrot set. We choose a window in the complex plane and associate pixels with points in the window. The pixels correspond to different values of the starting point s. A single value of c is chosen and then the orbit for each pixel position is examined to see if it explodes and if so, how quickly does it explodes. Pseudocode for drawing a region of the Filled-in Julia set for(j=0; j<rows; j++) for(i=0; i<cols; i++) estimate the dwell of the orbit find Color determined by estimated dwell setPixel( j , k, Color); } The dwell() must be passed to the starting point s as well as c. Making a high-resolution image of a Kc requires a great deal of computer time, since a complex calculation is associated with every pixel. The Julia Set Jc Julia Set Jc is for any given value of c; it is the boundary of Kc. Kc is the set of all starting points that have finite orbits and every point outside Kc has an exploding orbit. We say that the points just along the boundary of Kc and “on the fence”. Inside the boundary all orbits remain finite; just outside it, all orbits goes to infinity. Preimages and Fixed Points If the process started instead at f(s), the image of s, then the two orbits would be: s, f(s), f2(s), f3(s),…. (orbit of s) or f(s), f2(s), f3(s), f4(s),…. (orbit of f(s)) which have the same value forever. If the orbit of s is finite, then so is the orbit of its image f(s). All of the points in the orbit , if considered as starting points on their own, have orbits with thew same behavior: They all are finite or they all explode. Any starting point whose orbit passes through s has the same behavior as the orbit that start at s: The two orbits are

Lecture Notes