Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics CS 385 January 31, 2005. Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.

Similar presentations


Presentation on theme: "Computer Graphics CS 385 January 31, 2005. Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of."— Presentation transcript:

1 Computer Graphics CS 385 January 31, 2005

2 Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of detail and appearance is present A System having similar detail at all scales, leading to intricate patterns and unexpected features. A system with a non-integer dimension. Computer-generated images corresponding to mathematical equations, that repeat self-similar patterns at infinitely receding levels of organization.

3 The Mandelbrot Set

4

5 A Julia Set

6

7

8

9

10 The Sierpinski Gasket This object is defined recursively but its definition also has a random component. Nevertheless, the process always converges to a geometric object that looks the same. The theme here is: Order in Chaos

11 Non-Formal Description 1.Draw a triangle 2.Pick a point p in the triangle at random and draw it 3.Pick a vertex v of the triangle at random 4.Find the point q halfway between v and p 5.Go back to step 2 with q playing the role of p

12 Representing Points in OpenGL In OpenGL, a point is often called a vertex There is a family of functions that start out glVertex and can be used for various data types in either 2 or 3 dimensions.

13 Representing Points in OpenGL Examples of glVertex are glVertex2f and glVertex3i If the datatype is represented by the letter v, then this indicates that the function takes a pointer to an array as its argument.

14 #include void init(void) { glClearColor(1.0,1.0,1.0,1.0); glColor3f(0.0,0.0,0.0); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2f(0,0); glEnd(); glFlush(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutCreateWindow(“A Point”); glutDisplayFunc(display); init(); glutMainLoop(); return 0; }

15 More Examples glBegin(GL_POINTS); glVertex2f(0,0); glEnd(); glBegin(GL_LINES); glVertex2f(0,0); glVertex2f(1,1); glEnd(); glBegin(GL_LINES); glVertex2f(1,1); glVertex2f(-1,-1); glVertex2f(-1,1); glVertex2f(1,-1); glEnd();

16 Back to the Sierpinski Gasket Whenever the window needs to be redrawn, the OpenGL engine calls a function specified by the function glutDisplayFunc This function takes a function which take a void argument and returns a void. By convention, the function is often called display. Lets look at an implementation of a display function for the Sierpinski Gasket

17 typedef GLfloat point2[2]; void display(void) { //Create an arbitrary triangle point2 vertices[3]={ {0.0, 0.0}, {250.0,500.0},{500.0,0.0}}; //Pick an arbitray point in the triangle static point2 p = {75.0, 50.0}; int j; for (int k=0; k<5000; k++) { j=rand()%3; //pick a random vertex from 0,1 and 2 //Compute the new point p[0] = (p[0] + vertices[j][0])/2; p[1] = (p[1] + vertices[j][1])/2; //Display the new point glBegin(GL_POINTS); glVertex2fv(p); glEnd(); } glFlush(); }

18 glBegin arguments GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP GL_TRIANGLES GL_TRIANGLE_STRIP GL_QUAD_STRIP GL_TRIANGLE_FAN

19 Next Monday Text Color and an Introduction to Viewing


Download ppt "Computer Graphics CS 385 January 31, 2005. Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of."

Similar presentations


Ads by Google