1 / 39

Approaches to Infinity

Approaches to Infinity. CVGLab. Goals of the Chapter. To examine the effective use of repetition and recursion in creating figures. To extend the ability to visualize complex patterns. To use recursion to draw space-filling curves. To construct fractal curves and trees.

fleur
Download Presentation

Approaches to Infinity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Approaches to Infinity CVGLab

  2. Goals of the Chapter • To examine the effective use of repetition and recursion in creating figures. • To extend the ability to visualize complex patterns. • To use recursion to draw space-filling curves. • To construct fractal curves and trees. • To examine fractal image compression. • To examine the nature, and construct pictures of, the Mandelbrot and Julia sets. • To develop methods for “fractalizing” a curve using random fractals.

  3. Introduction • Repetition -. Will do something again and again without complaint complaint. -. The high precision with which modern computers can do calculations allows an algorithm to take closer and closer “looks” at an object, effectively “zooming in” to ever greater levels of detail.

  4. Fractals and Self-similarity • Recursion – open makes a difficult geometric task extremely simple. • Recursive algorithms – con give rise to shapes that are both lovely and intriguing or that have useful applications in science and engineering. • Self-similar – appear “ the same” at every scale. • exactly self-similar – the enlargement looks exactly like the original. • Statistically self-similar – the wiggles and irregularities in the curve are the same “on the average,” • Fractals – various forms of self-similar curves.

  5. Fractals and Self-similarity • Successive Refinement of Curves -. Koch curve : to form Kn+1 from Kn;

  6. Fractals and Self-similarity • Drawing Koch Curves and Snowflakes -. N : the order of the curve Kn the order-n Koch curve consists of four versions of the order (n-1) Koch curve.

  7. Fractals and Self-similarity • Fractional Dimension -. Dimension : appears in the exponent of N Where, an object has dimension D if, when it is subdivided into N equal parts. -. Peano curves

  8. String Production and Peano Curves • L-Systems – to draw complex curves based on a simple set of rules. • A command to perform some operation: -. ‘F’ means forward (1, 1) (go forward visibly a distance 1 in the current direction). -. ‘+’ means turn (A) (turn right through angle A degrees). -. ‘-’ means turn (-A) (turn left through angle A degrees).

  9. World Windows and Viewports • Setting the Window and Viewport Automaticall • Setting of the Window • -. Extent(or bounding box) -. For finding the routine the extend may have to be run twice, a different way each time: Pass1. Execute the drawing routine, but do no actual drawing;just compute the extent. Then set the window. Pass2. Execute the drawing routine again. Do the actual drawing.

  10. World Windows and Viewports • Automatic Setting of the Viewport to Preserve the Aspect Ratio. -. A common wish is to find the largest such viewport that will fit inside the screen window on the display.

  11. World Windows and Viewports • Resizing the Screen window; the Resize Event -. Resize : typically by dragging one of its corners with the mouse. glut ReshapeFunc (myReshape); // specifies the function called on a resize // event void myReshape (Glsizei W, Glsizei H); • Making a Matched Viewport -. Using a reshape function to set the largest matching viewport upon a resize event

  12. Clipping Lines • Clipping – a fundamental task in graphics, needed to keep those parts of an object that lie outside a given region from being drawn. • Clipping a Line the Cohen-Sutherland clipper: a classic line-clipping algorithm • like segment CD, the function returns a value of 1. • like segment AB, the function returns a value of 0 • like segment ED, the function clips the portion of the segment that lies outside the window and returns a value of 1. • like segment AE, the function clips both ends and returns a value of 1.

  13. Clipping Lines • The Cohen-Sutherland Clipping Algorithm -. “trivial accept” : no clipping(a large window). -. “trivial reject”: nothing is drawn(a small window). • Testing for a Trivial Accept or Trivial Reject -. “inside-outside code word”

  14. Clipping Lines • Trivial accept: Both code words are FFFF; • Trivial reject: The code words have a T in the same position; both points are to the left of the window, or both are above, etc.

  15. Clipping Lines • Chopping When There Is Neither Trivial Accept nor Trivial Reject

  16. Clipping Lines

  17. Developing the Canvas Class • Canvas class -. Provides a handy drawing canvas on which to draw the lines, polygons, etc. of interest. -. This class provides simple methods for creating the desired screen window and establishing a world window and viewport, and it ensures that the window-to-viewport mapping is well defined.

  18. Developing the Canvas Class • Some Useful Supporting Class • Class Point2 : A Point Having Real Coordinates. class Point2 { public: Point2() {x = y = 0.0f;} //constructor1 Point2 (float xx, float yy) {x = xx; y = yy;} //constructor2 void set (float xx, float yy) {x = xx; y = yy;} float getX () {return x;} float getY () {return y;} void draw (void) {glGegin (GL_POINTS); glVertexf ((GLfloat)x, (GLfloat)y); glEnd ();} private: float x, y;};

  19. Developing the Canvas Class • Class IntRect : An Aligned Rectangle with Integer Coordinates class IntRect { public: IntRect () {1 = 0; r = 100; b = 0; t = 100;} // constructors IntRect (int left, int right, int bottom, int top) {l = left; r = right; b = bottom; t = top;} void set (int left, int right, int bottom, int top) {l = left; r = right; b = bottom; t = top;} void draw (void) // draw this rectangle using OpenGL private: int l, r, b, t; };

  20. Developing the Canvas Class • Class RealRect : An Aligned Rectangle with Integer Coordinates class RealRect { same as intRect except use float instead of int };

  21. Developing the Canvas Class • Declaration of Class Canvas

  22. Developing the Canvas Class • Implementation of Class Canvas

  23. Developing the Canvas Class

  24. Relative Drawing • Developing moveRel() and lineRel() -. moveRel(), lineRel(): “moves” the CP through the displacement (dx, dy)

  25. Relative Drawing • Turtle Graphics -. Three functions: 1) turnTo (float angle): void Canvas : : turnTo (float angle) {CD = angle;} 2) turn (float angle): void Canvas : : turn (angle) {CD += angle;} 3) forward (float dist, int isVisible) void Canvas:: forward(float dist, int isVisible) { const float RadPerDeg = 0.017453393; //radians per degree float x = CP.x + dist * cos(RadPerDeg * CD); float y = CP.y + dist * sin(RadPseDeg * CD); if(isVisible) lineTo(x, y); else moveTo(x, y);}

  26. Figures Based on Regular Polygons • The Regular Polygons Definition: A polygon is regular if it is simple, if all its sides have equal lengths, and if adjacent sides meet at equal interior angles. -. n-gon: to a regular polygon having n sides.

  27. Figures Based on Regular Polygons

  28. Figures Based on Regular Polygons • Drawing a hexagon. for (i = 0; i < 6; i++) { cvs.forward(L, 1); cvs.turn(60); } A 7-gon and its offspring

  29. Drawing Circles and Arcs • Drawing a circle is equivalent to drawing an n-gon that has a large number of vertices. • Drawing Arcs • -. Defining an arc.

  30. Drawing Circles and Arcs • drawCircle(): -. By specifying a center and radius. -. The center is given, along with a point on the circle. -. Three points are given through which the circle must pass.

  31. Using the Parametric Form for a Curve • Two principal ways to describe the shape of a curved line: -. implicitly -. Parametrically • Implicit form: describes a curve by a function F(x, y) that provides a relationship between the x and y coordinates. • inside-outside function

  32. Using the Parametric Form for a Curve • single valued • not single valued

  33. Using the Parametric Form for a Curve • Parametric Forms for Curves • Examples: The Line and the Ellipse -. line : parametric form that visits A at t = 0 and B at t = 1, -. ellipse : parametrically by

  34. Using the Parametric Form for a Curve • Finding an Implicit Form from a Parametric Form • Drawing Curves Represented Parametrically

  35. Using the Parametric Form for a Curve • Superellipses -. Implicit formula -. parametric representation -. n > 1 the bulge is outward, n < 1 the bulge is inward, n = 1 the supercircle becomes a square.

  36. Using the Parametric Form for a Curve • superhyperbola -. parametric representation -. n = 1 becoming straight n < 1 pinching inward

  37. Using the Parametric Form for a Curve • Polar Coordinate Shapes -.Polar coordinates -. Examples of curves with simple polar forms. . Cardioid: f(θ) = k(1 + cos(θ)). . Rose curves: f(θ) = k cos(nθ), where n specifies the number of petals in the rose. Two cases are shown. . Archimedean spiral: f(θ) = kθ.

  38. Using the Parametric Form for a Curve -. conic sections Where e is the eccentricity of the section for e = 1, the shape is a parabola; for 0 <= e < 1, it is an ellipse; And for e > 1, it is a hyperbola. -. Logarithmic spiral Where a = cot(α)

  39. Using the Parametric Form for a Curve 5. 3D Curves • The helix • The helix • The toroidal spiral

More Related