590 likes | 852 Views
Lecture 37 of 42. Intro to Fractals and L-Systems. Monday, 28 April 2008 William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636
E N D
Lecture 37 of 42 Intro to Fractals and L-Systems Monday, 28 April 2008 William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636 Instructor home page: http://www.cis.ksu.edu/~bhsu Readings: Handouts from Barnsley CIS 636/736: (Introduction to) Computer Graphics
Computer Graphics 11:3D Object Representations –Octrees & Fractals Course Website:http://www.comp.dit.ie/bmacnamee CIS 636/736: (Introduction to) Computer Graphics
“Clouds are not spheres, mountains are not cones, coastlines are not circles and bark is not smooth, nor does lightning travel in a straight line.” Benoit Mandelbrot Fractals • All of the modelling techniques covered so far use Euclidean geometry methods • Objects were described using equations • This is fine for manufactured objects • But what about natural objects that have irregular or fragmented features? • Mountains, clouds, coral… CIS 636/736: (Introduction to) Computer Graphics
Fractal Geometry Methods & Procedural Modelling • Natural objects can be realistically described using fractal geometry methods • Fractal methods use procedures rather than equations to model objects - procedural modelling • The major characteristic of any procedural model is that the model is not based on data, but rather on the implementation of a procedure following a particular set of rules Modelling On The Fly! CIS 636/736: (Introduction to) Computer Graphics
Mandelbrot Set Video From:http://www.fractal-animation.net/ufvp.htm Fractals • A fractal object has two basic characteristics: • Infinite detail at every point • A certain self similarity between object parts and the overall features of the object The Koch Curve CIS 636/736: (Introduction to) Computer Graphics
Generating Fractals • A fractal object is generated by repeatedly applying a specified transform function to points in a region of space • If P0 = (x0, y0, z0) is a selected initial position, each iteration of a transformation function F generates successive levels of detail with the calculations: • In general the transformation is applied to a specified point set, or to a set of primitives (e.g. lines, curves, surfaces) CIS 636/736: (Introduction to) Computer Graphics
Generating Fractals (cont…) • Although fractal objects, by definition have infinite detail, we only apply the transformation a finite number of times • Obviously objects we display have finite dimension – they fit on a page or a screen • A procedural representation approaches a true representation as we increase the number of iterations • The amount of detail is limited by the resolution of the display device, but we can always zoom in for further detail CIS 636/736: (Introduction to) Computer Graphics
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) Example: The Koch Snowflake CIS 636/736: (Introduction to) Computer Graphics
Example: Ferns • Very similar techniques can be used to generate vegetation CIS 636/736: (Introduction to) Computer Graphics
Fractal Dimension • The amount of variation in the structure of a fractal object is described as the fractal dimension, D • More jagged looking objects have larger fractal dimensions • Calculating the fractal dimension can be difficult, especially for particularly complex fractals • We won’t look at the details of these calculations CIS 636/736: (Introduction to) Computer Graphics
Types Of Fractals • Fractals can be classified into three groups • Self similar fractals • These have parts that are scaled down versions of the entire object • Commonly used to model trees, shrubs etc • Self affine fractals • Have parts that are formed with different scaling parameters in each dimension • Typically used for terrain, water and clouds • Invariant fractal sets • Fractals formed with non-linear transformations • Mandelbrot set, Julia set – generally not so useful CIS 636/736: (Introduction to) Computer Graphics
Random Midpoint Displacement Methods For Topography • One of the most successful uses of fractal techniques in graphics is the generation of landscapes • One efficient method for doing this is random midpoint displacement CIS 636/736: (Introduction to) Computer Graphics
Random Midpoint Displacement Methods For Topography (cont…) • Easy to do in two dimensions • Easily expanded to three dimensions to generate terrain • Can introduce a roughness factor H to control terrain appearance • Control surfaces can be used to start with a general terrain shape Terrain generation demo: http://world.std.com/~bgw/applets/1.02/MtFractal/MtFractal.html CIS 636/736: (Introduction to) Computer Graphics
Fractals In Film Special Effects CIS 636/736: (Introduction to) Computer Graphics
CS G140Graduate Computer Graphics Prof. Harriet Fell Spring 2007 Lecture 9 – March 26, 2007 CIS 636/736: (Introduction to) Computer Graphics
Fractals The term fractal was coined in 1975 by Benoît Mandelbrot, from the Latin fractus, meaning "broken" or "fractured". (colloquial) a shape that is recursively constructed or self-similar, that is, a shape that appears similar at all scales of magnification. (mathematics) a geometric object that has a Hausdorff dimension greater than its topological dimension. CIS 636/736: (Introduction to) Computer Graphics
Mandelbrot Set Mandelbrotset, rendered with Evercat's program. CIS 636/736: (Introduction to) Computer Graphics
Mandelbrot Set CIS 636/736: (Introduction to) Computer Graphics
What is the Mandelbrot Set? We start with a quadratic function on the complex numbers. The Mandelbrot Set is the set of complex csuch that CIS 636/736: (Introduction to) Computer Graphics
Example CIS 636/736: (Introduction to) Computer Graphics
(Filled-in) Julia Sets c = –1 c = –.5 +.5i c = – 5 +.5i The Julia Set of fc is the set of points with 'chaotic' behavior under iteration. Thefilled-in Julia set (or Prisoner Set), is the set of all z whos orbits do not tend towards infinity. The "normal" Julia set is the boundary of the filled-in Julia set. CIS 636/736: (Introduction to) Computer Graphics
Julia Sets and the Mandelbrot Set Some Julia sets are connected others are not. The Mandelbrot set is the set of c for which the Julia set of fc(z) = z2 + c is connected. Map of 121 Julia sets in position over the Mandelbrot set (wikipedia) CIS 636/736: (Introduction to) Computer Graphics
A fractal is formed when pulling apart two glue-covered acrylic sheets. CIS 636/736: (Introduction to) Computer Graphics
Fractal Form of a Romanesco Broccoliphoto by Jon Sullivan CIS 636/736: (Introduction to) Computer Graphics
Time for a Break CIS 636/736: (Introduction to) Computer Graphics
L-Systems • An L-system or Lindenmayer system, after Aristid Lindenmayer (1925–1989), is a formal grammar (a set of rules and symbols) most famously used to model the growth processes of plant development, though able to model the morphology of a variety of organisms. • L-systems can also be used to generate self-similar fractals such as iterated function systems. CIS 636/736: (Introduction to) Computer Graphics
L-System References • Przemyslaw Prusinkiewicz & Aristid Lindenmayer, “The Algorithmic Beauty of Plants,” Springer, 1996. • http://en.wikipedia.org/wiki/L-System CIS 636/736: (Introduction to) Computer Graphics
L-System Grammar • G = {V, S, ω, P}, where • V (the alphabet) is a set of variables • S is a set of constant symbols • ω (start, axiom or initiator) is a string of symbols from V defining the initial state of the system • P is a set of rules or productions defining the way variables can be replaced with combinations of constants and other variables. • A production consists of two strings - the predecessor and the successor. CIS 636/736: (Introduction to) Computer Graphics
L-System Examples • Koch curve (from wikipedia) • A variant which uses only right-angles. • variables : F • constants : + − • start : F • rules : (F → F+F−F−F+F) • Here, F means "draw forward", + means "turn left 90°", and - means "turn right 90°" (see turtle graphics). CIS 636/736: (Introduction to) Computer Graphics
Turtle Graphics class Turtle { double angle; // direction of turtle motion in degrees double X; // current x position double Y; // current y position double step; // step size of turtle motion boolean pen; // true if the pen is down public void forward(Graphics g) // moves turtle forward distancestepin directionangle public void turn(double ang) // setsangle = angle + ang; public void penDown(), public void penUp() // setpento true or false } CIS 636/736: (Introduction to) Computer Graphics
F F+F-F-F+F My L-System Data Files Koch Triangle Form // title 4 // number of levels to iterate 90 // angle to turn F // starting shape F:F+F-F-F+F // a rule Go to Eclipse F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F CIS 636/736: (Introduction to) Computer Graphics
L L+R+ L+R+ + -L-R + More Variables Dragon When drawing, treat L and R just like F. 10 90 L L:L+R+ R:-L-R L+R+ + -L-R ++- L+R+ - -L-R + CIS 636/736: (Introduction to) Computer Graphics
R A Different Angle Sierpinski Gasket 6 60 R L:R+L+R R:L-R-L L-R-L R+L+R- L-R-L -R+L+R CIS 636/736: (Introduction to) Computer Graphics
Moving with Pen Up Islands and Lakes 2 90 F+F+F+F F:F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF f:ffffff // f means move forward with the pen up next slide F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF F+F+F+F CIS 636/736: (Introduction to) Computer Graphics
Islands and LakesOne Side of the Box F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF CIS 636/736: (Introduction to) Computer Graphics
Using a Stack to Make Trees Tree1 [ push the turtle state onto the stack 4 ] pop the turtle state from the stack 22.5 F F:FF-[-F+F+F]+[+F-F-F] and I add leaves here FF-[-F+F+F]+[+F-F-F] CIS 636/736: (Introduction to) Computer Graphics
Stochastic L-Systemshttp://algorithmicbotany.org/lstudio/CPFGman.pdf seed: 2454 // different seeds for different trees derivation length: 3 axiom: F F--> F[+F]F[-F]F : 1/3 F--> F[+F]F : 1/3 F--> F[-F]F : 1/3 CIS 636/736: (Introduction to) Computer Graphics
3D Turtle Rotations Heading, Left, or, Up vector tell turtle direction. +(θ) Turn left by angle θ◦ around the U axis. −(θ) Turn right by angle θ◦ around the U axis. &(θ) Pitch down by angle θ◦ around the L axis. ∧(θ) Pitch up by angle θ◦ around the L axis. \(θ) Rollleftbyangleθ◦ around the H axis. /(θ) Roll right by angle θ◦ around the H axis. | Turn around 180◦ around the U axis. @v Roll the turtle around the H axis so that H and U lie in a common vertical plane with U closest to up. CIS 636/736: (Introduction to) Computer Graphics
A Mint http://algorithmicbotany.org/papers/ A model of a member of the mint family that exhibits a basipetal flowering sequence. CIS 636/736: (Introduction to) Computer Graphics
Examining the World of Fractals Myles Akeem SingletonCentral Illinois Chapter National BDPA Technology Conference 2006Los-Angeles, CA CIS 636/736: (Introduction to) Computer Graphics
Content of presentation • Introduction to fractals • L-systems/Production rules • Plant images • Turtle geometry • Conclusion CIS 636/736: (Introduction to) Computer Graphics
Introduction to fractals • Fractal • Geometric • Self-similar • Has fractional dimension • Categorized under chaos science - fractal geometry • 1975 - Benoît Mandelbrot defined the term fractal from the Latin fractus, “broken” or “fractured” CIS 636/736: (Introduction to) Computer Graphics
Example of self-similarity CIS 636/736: (Introduction to) Computer Graphics
Koch Snowflake iterations CIS 636/736: (Introduction to) Computer Graphics
Julia set graphic CIS 636/736: (Introduction to) Computer Graphics
Introduction to L-systems • Fibonacci • Thu-Morse • Paperfolding • Dragon curve • Turtle graphics • Branching • Bracketed • Several biological forms are branched, fragmented, or cellular in appearance and growth • Example where a trunk emerges from a branch: CIS 636/736: (Introduction to) Computer Graphics
Production rules • 1968 - biologist Aristid Lindenmayer invents the L-system formula • Used as a grammar to model the growth pattern of a type of algae • Set of production rules: Rule 1: a → ab Rule 2: b → a CIS 636/736: (Introduction to) Computer Graphics
Deterministic, context-free Lindenmayer system (D0L system) Rule 1: a → ab Rule 2: b → a • b → a • a → ab • ab → aba • aba → abaab • abaab → abaababa CIS 636/736: (Introduction to) Computer Graphics
Ben Hesper and Pauline Hogeweg • Two of Lindenmayer’s graduate students • Tested to see if L - systems could resemble botanic forms • Images controlled by special characters would draw an image onto a screen F → move forward one, drawing f → move forward one, without drawing + → rotate clockwise by a given angle - → rotate counterclockwise by a given angle [ → push into stack ] → pop from stack CIS 636/736: (Introduction to) Computer Graphics
Koch Island example“F → F + F - F - FF + F + F - F” F → move forward one, drawing + → rotate clockwise by a given angle - → rotate counterclockwise by a given angle CIS 636/736: (Introduction to) Computer Graphics