Fractals & Iterative Function Systems

Similar documents
IMGD 4000 Technical Game Development II Procedural Content Generation

Computer Graphics (CS 543) Lecture 2c: Fractals. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics 4731 Lecture 5: Fractals. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

CS 543: Computer Graphics Lecture 3 (Part I): Fractals. Emmanuel Agu

Procedural modeling and shadow mapping. Computer Graphics CSE 167 Lecture 15

CSC 470 Computer Graphics. Fractals

CSE 167: Lecture #17: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CSE 167: Lecture #15: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Fractals Week 10, Lecture 19

Fractals: a way to represent natural objects

Fractal Coding. CS 6723 Image Processing Fall 2013

CGT 581 G Procedural Methods Fractals

Session 27: Fractals - Handout

Mathematics 350 Section 6.3 Introduction to Fractals

CSE 167: Introduction to Computer Graphics Lecture #16: Procedural Modeling

L-Systems and Affine Transformations

Outline. Solid models and fractals. Constructive solid geometry. Constructive solid geometry COM3404. Richard Everson

Clouds, biological growth, and coastlines are

Fractals and L- Systems

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2012 Lecture 28 November 8, 2012

Solid models and fractals

Fractals and Multi-Layer Coloring Algorithms

Fractals in Nature and Mathematics: From Simplicity to Complexity

Mathematics in Computer Graphics and Games. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

An Introduction to Fractals

Generation of 3D Fractal Images for Mandelbrot and Julia Sets

Fractals. Materials. Pencil Paper Grid made of triangles

Fractals. Moreno Marzolla Dip. di Informatica Scienza e Ingegneria (DISI) Università di Bologna.

Fractals. Fractals. Beautiful designs of infinite structure and complexity Qualities of Fractals:

<The von Koch Snowflake Investigation> properties of fractals is self-similarity. It means that we can magnify them many times and after every

Chapel Hill Math Circle: Symmetry and Fractals

Subdivision Of Triangular Terrain Mesh Breckon, Chenney, Hobbs, Hoppe, Watts

Lecture 6: Fractals from Iterated Function Systems. He draweth also the mighty with his power: Job 24:22

Total 80

Fractal Image Compression


CS 543: Computer Graphics. Introduction

Fractals: Self-Similarity and Fractal Dimension Math 198, Spring 2013

More modelling. Ruth Aylett

Fractal Geometry. Prof. Thomas Bäck Fractal Geometry 1. Natural Computing Group

Definitions. Modeling. Primitives. Creating a model of an object, usually out of a collection of simpler primitives

Fun with Fractals Saturday Morning Math Group

9. Three Dimensional Object Representations

Synthetic Landscapes

12.2 Plants. CS Dept, UK

Fractal Geometry. LIACS Natural Computing Group Leiden University

Lecture 6: Fractals from Iterated Function Systems. He draweth also the mighty with his power: Job 24:22

lecture 9 Object hierarchies - call trees and GL_MODELVIEW stack - fractals - L systems

Exploring the Effect of Direction on Vector-Based Fractals

Grade 6 Math Circles. Shapeshifting

Textures III. Week 10, Wed Mar 24

Topics. Recursive tree models. Procedural approach L-systems. Image-based approach. Billboarding

Copyright 2009 Pearson Education, Inc. Chapter 9 Section 7 - Slide 1 AND

Exploring Fractals through Geometry and Algebra. Kelly Deckelman Ben Eggleston Laura Mckenzie Patricia Parker-Davis Deanna Voss

Midterm Project: L-systems in Practice and Theory

In this lesson, students build fractals and track the growth of fractal measurements using tables and equations. Enduring Understanding

Fun with Fractals and Functions. CHAMP at University of Houston March 2, 2015 Houston, Texas

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

CS 543: Computer Graphics. Rasterization

Computer Science 173 Fall, Project 3: Lindenmayer Systems Due in class on Monday, September 28

Fractals, Fibonacci numbers in Nature 17 mai 2015

Hei nz-ottopeitgen. Hartmut Jürgens Dietmar Sau pe. Chaos and Fractals. New Frontiers of Science

Procedural Genera-on Natural Environments Out Of The Box

MITOCW 2. IV: Consistency, Completeness, and Geometry

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Lecture 3: Some Strange Properties of Fractal Curves

7. Stochastic Fractals

CGT 511 Procedural Methods

Fractal Dimension and the Cantor Set

Self-Similar Snowflakes with Optional Fractal Extension

Computer Graphics. Prof. Feng Liu. Fall /21/2016

Discovering. Algebra. An Investigative Approach. Condensed Lessons for Make-up Work

Images of some fractals

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Space Filling: A new algorithm for procedural creation of game assets

Lectures on Challenging Mathematics. Integrated Mathematics 3. Idea Math. Algebra (part 2) Summer Internal Use

Creating a Snowman Scene

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Turtle Graphics and L-systems Informatics 1 Functional Programming: Tutorial 7

Applications. 44 Stretching and Shrinking

REGULATIONS Team: Submission: Late Submission: only for one day Cheating: Updates: Newsgroup: must

ECE 600, Dr. Farag, Summer 09

CS 543: Computer Graphics. Projection

TRANSFORMATIONS. The original figure is called the pre-image; the new (copied) picture is called the image of the transformation.

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

2D Drawing Primitives

Some geometries to describe nature

Fractals and the Chaos Game

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Recall: Indexing into Cube Map

Curves and Surfaces. Shireen Elhabian and Aly A. Farag University of Louisville

CMSC427 Final Practice v2 Fall 2017

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Computer Graphics CS 543 Lecture 1 (Part I) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Chapter 13 - Modifiers

Chapter 12: Fractal Geometry The Koch Snowflake and Self-Similarity

The Koch curve in three dimensions

Transcription:

CS 543: Computer Graphics Fractals & Iterative Function Systems Robert W. Lindeman Associate Professor Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu (with lots of help from Prof. Emmanuel Agu :-)

What are Fractals?! Mathematical expressions! Approach infinity in organized way! Utilize recursion on computers! Popularized by Benoit Mandelbrot (Yale University)! Dimensionality " Line is one-dimensional " Plane is two-dimensional " Fractals fall somewhere in between! Defined in terms of self-similarity Interactive Media & Game Development 2

Self Similarity! Level of detail remains the same as we zoom in! Example " Surface roughness, or silhouette, of mountains is the same at many zoom levels " Difficult to determine scale! Types or fractals " Exactly self-similar " Statistically self-similar Interactive Media & Game Development 3

Examples of Fractals! Modeling mountains (terrain)! Clouds! Fire! Branches of a tree! Grass! Coastlines! Surface of a sponge! Cracks in the pavement! Designing antennae (www.fractenna.com) Interactive Media & Game Development 4

Examples of Fractals: Mountains Interactive Images: Media www.kenmusgrave.com & Game Development 5

Examples of Fractals: Clouds Images: www.kenmusgrave.com Interactive Media & Game Development 6

Examples of Fractals: Fire Images: www.kenmusgrave.com Interactive Media & Game Development 7

Examples of Fractals: Comets? Images: www.kenmusgrave.com Interactive Media & Game Development 8

Koch Curves! Discovered in 1904 by Helge von Koch! Start with straight line of length 1! Recursively " Divide line into three equal parts " Replace middle section with triangular bump with sides of length 1/3 " New length = 4/3 Interactive Media & Game Development 9

Koch Snowflake! Can form Koch snowflake by joining three Koch curves! Perimeter of snowflake grows as: ( ) i P i = 3 4 3 where P i is the perimeter of the ith snowflake iteration! However, area grows slowly as S = 8/5!! Self similar " Zoom in on any portion " If n is large enough, shape is the same " On computer, smallest line segent > pixel spacing www.jimloy.com Interactive Media & Game Development 10

Koch Snowflake S 3 S 4 S 5 Interactive Media & Game Development 11

Psedocode to draw Koch Curve if (n equals 0) { draw straight line } else { Draw K n-1 Turn left 60 Draw K n-1 Turn right 120 Draw K n-1 Turn left 60 } Draw K n-1 Interactive Media & Game Development 12

Gingerbread Man # Each new point q is formed from previous point p using the equation # For 640 x 480 display area, use M = 40 L = 3 # A good starting point is (115, 121) Interactive Media & Game Development 13

Iterated Function Systems (IFS)! Subdivide! Recursively call a function! Does result converge to an image? What image?! IFS do converge to an image! Examples " The Fern " The Mandelbrot set Interactive Media & Game Development 14

Example: Ferns 15

Fractals and Self-Similarity! Exact Self-similarity " Each small portion of the fractal is a reduced-scale replica of the whole (except for a possible rotation and shift).! Statistical Self-similarity " The irregularities in the curve are statistically the same, no matter how many times the picture is enlarged. 16

The Fern! Any (sub) branch looks similar to any other (sub) branch! Including ancestors and descendents Interactive Media & Game Development 17

Mandelbrot Set Interactive Media & Game Development 18

Fractal Coastline 19

Examples of Fractals: Trees Fractals appear the same at every scale. 20

Fractal Dimension Eg. 2 The Sierpinski Triangle D = log log & $ % N 1 s #! " N = 3, s = ½ D =1.584 21

Space-Filling Curves! There are fractal curves which completely fill up higher dimensional spaces such as squares or cubes.! The space-filling curves are also known as Peano curves (Giuseppe Peano: 1858-1932).! Space-filling curves in 2D have a fractal dimension 2. You re not expected to be able to prove this. 22

Hilbert Curve! Discovered by German Scien9st, David Hilbert in late 1900s! Space filling curve! Drawn by connec9ng centers of 4 sub- squares, make up larger square.! Itera9on 0: 3 segments connect 4 centers in upside- down U Iteration 0 Interactive Media & Game Development 23

Hilbert Curve: Itera9on 1! Each of 4 squares divided into 4 more squares! U shape shrunk to half its original size, copied into 4 sectors! In top len, simply copied, top right: it's flipped ver9cally! In the boqom len, rotated 90 degrees clockwise,! BoQom right, rotated 90 degrees counter- clockwise.! 4 pieces connected with 3 segments, each of which is same size as the shrunken pieces of the U shape (in red) Interactive Media & Game Development 24

Hilbert Curve: Itera9on 2! Each of the 16 squares from itera9on 1 divided into 4 squares! Shape from itera9on 1 shrunk and copied.! 3 connec9ng segments (shown in red) are added to complete the curve.! Implementa9on? Recursion is your friend!! Interactive Media & Game Development 25

Space-Filling Curves 26

Space-Filling Curves in 3D 27

Generating Fractals! Iterative/recursive subdivision techniques! Grammar based systems (L-Systems) " Suitable for turtle graphics/vector devices! Iterated Functions Systems (IFS) " Suitable for raster devices 28

L-Systems ( Lindenmayer Systems )! A grammar-based model for generating simple fractal curves " Devised by biologist Aristid Lindenmayer for modeling cell growth " Particularly suited for rendering line drawings of fractal curves using turtle graphics! Consists of a start string (axiom) and a set of replacement rules " At each iteration all replacement rules are applied to the string in parallel! Common symbols: " F Move forward one unit in the current direction. " + Turn right through an angle A. " - Turn left through an angle A. 29

The Koch Curve Axiom: F (the zeroth order Koch curve) Rule: F F-F++F-F Angle: 60 First order: F-F++F-F 60 120 Order 0 1 Second order: F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F 2 30

The Dragon Curve Axiom: FX Rules: F X +FX FY+ Y FX++FY Angle: 45 At each step, replace a straight segment with a right angled elbow. Alternate right and left elbows. FX and FY are embryonic right and left elbows respectively. 31

L-System code import turtle turtle.speed(0) # Max speed (still horribly slow) def draw(start, rules, angle, step, maxdepth): for char in start: if maxdepth == 0: if char == 'F': turtle.forward(step) elif char == '-': turtle.left(angle) elif char == '+': turtle.right(angle) else: if char in rules: # rules is a dictionary char = rules[char] draw(char, rules, angle, step, maxdepth-1) # Dragon example: draw("fx",{'f':"",'x':"+fx--fy+",'y':" FX++FY "}, 45, 5, 10) 32

Generalized Grammars! The grammar rules in L-systems can be further generalized to provide the capability of drawing branchlike figures, rather than just continuous curves.! The symbol [ is used to store the current state of the turtle (position and direction) in a stack for later use.! The symbol ] is used to perform a pop operation on the stack to restore the turtle s state to a previously stored value. 33

Generalized Grammars Fractal bush: S F F FF-[-F+F+F]+[+F-F-F] (A = 22 degs.) Zero order bush F Fourth order bush (with 90 deg. rotation) First order bush 34

Random Fractals! Natural objects do not contain identical scaled down copies within themselves and so are not exact fractals.! Practically every example observed involves what appears to be some element of randomness, perhaps due to the interactions of very many small parts of the process.! Almost all algorithms for generating fractal landscapes effectively add random irregularities to the surface at smaller and smaller scales. 35

Random Fractals! Random fractals are " randomly generated curves that exhibit self-similarity, or " deterministic fractals modified using random variables! Random fractals are used to model many natural shapes such as trees, clouds, and mountains. 36

IFS Example: Generating Fractal Terrain (2D) 1. Choose a randomnumber range 2. Start with a line 3. Find the midpoint 4. Displace it in y by a random amount 5. Reduce the range of your random numbers $ Controls roughness 6. Recurse on both new segments Interactive Media & Game Development 37

Random Midpoint Displacement Algorithm (2D)! Subdivide a line segment into two parts, by displacing the midpoint by a random amount g. i.e., y- coordinate of C is A C g B y C = ( y A + y B )/2 + g " Generate g using a Gaussian random variable with zero mean (allowing negative values) and standard deviation s.! Recurse on each new part " At each level of recursion, the standard deviation is scaled by a factor (1/2) H! H is a constant between 0 and 1! H = 1 in the example on the right 38

Midpoint Displacement Algorithm (3D) Square-Step: Subdivide a ground square into four parts, by displacing the midpoint by a Gaussian random variable g with mean 0, std dev s. i.e., Compute y-coordinate of E as y E = ( y A + y B + y C + y D )/4 + g Do that for all squares in the grid (only 1 square for the first iteration). Then... Z D A E X C B 39

Diamond step! To get back to a regular grid, we now need new vertices at all the edge mid-points too.! For this we use a diamond step: Do this for all edges (i.e., all possible diamonds). Vertices before square step New vertices from square step Vertex from diamond step (on an old edge midpoint). Computed as in square step but using the 4 diamond vertices. 40

Diamond step (cont d) Reflect vertices at grid edges to make diamonds there. 41

Diamond-Square Algorithm The above two steps are repeated for the new mesh, after scaling the standard deviation of g by (1/2) H. And so on H=0.4 H=0.8 42

Diamond Step Process 1 st pass 2 nd pass 5 th pass 43

Height Maps! The 2D height map obtained using the diamond-square algorithm can be used to generate fractal clouds.! Use the y value to generate opacity. 44

Useful Links! Terragen terrain generator " http://www.planetside.co.uk/terragen/! Generating Random Fractal Terrain " http://www.gameprogrammer.com/fractal.html! Lighthouse 3D OpenGL Terrain Tutorial " http://www.lighthouse3d.com/opengl/terrain/! Book about Procedural Content Generation " Noor Shaker, Julian Togelius, Mark J. Nelson, Procedural Content Generation in Games: A Textbook and an Overview of Current Research (Springer), 2014.! Book about Procedural Generation David S. Ebert, F. Kenton Musgrave, Darwyn Peachey, Ken Perlin, Steve Worley. Texturing and Modeling: A Procedural Approach (The Morgan Kaufmann Series in Computer Graphics) 45

References! Angel and Shreiner, Interac9ve Computer Graphics, 6 th edi9on, Chapter 9! Hill and Kelley, Computer Graphics using OpenGL, 3 rd edi9on, Appendix 4 Interactive Media & Game Development 46