You are on page 1of 11

UNIT 5

FRACTALS
Fractals and Self-Similarity

• Fractals are geometric objects

• Fractals are formed by iterations.

• Fractals are self-similar.

• Many real-world objects like ferns are shaped like fractals.

Fractal generation Procedures

If p0 = (x0,y0,z0) is a selected intital point, each iteration of the transformation function F


generate the successive level as

p1=F(p0) , p2 = F(p1) , p3 = F(p2) …..

Fractals Types

Fractals can also be classified according to their Self-Similarity. There are three types of Self-
Similarity found in fractals

 Exactly Self-Similarity

 Quasi Self-Similarity

 Statistically Self-Similarity

Exactly Self-Similarity

This is the strongest type of self-similarity

This fractal appears identical at different scales

Fractals defined by iterated function system (IFS) often display exact self-similarity.

Example : Koch curve, Peano Curve, Sierpinski Triangle

Quasi self-similarity

This is a loose form of self-similarity

This fractal approximates the same pattern at different scales; may contain small copies of the
entire fractal in distorted and degenerate forms; e.g., the Mandelbrot set, Julia set.
Statistical self-similarity

This is the weakest type of self-similarity.

This fractal repeats a pattern stochastically. So numerical or statistical measures are preserved
across scales; e.g., randomly generated fractals like mountain, clouds, seashore etc.

Fractal Dimension

Let D be the Fractal dimension of the Fractal object

Subdivide the objects into N equal parts

Each part is made smaller on each side by r

N=rD
Take the log on both sides and get log(N) = D log(r).

D = log (N)/log(r)

Sierpinski Triangle

It can be generated by infinitely repeating a procedure of connecting the midpoints of each side
of the triangle to form four separate triangles, and cutting out the triangle in the center.

Construction of Sierpinski Triangle

Let the successive generations of the Sierpinski Triangle be S0,S1,S2….

Step 1 - Initiator : Start with the equilateral triangle

S0 :

Initiator - S0

Step 2 - Connect the midpoints of each side of the triangle to form four separate triangles.

S1 :

Step 3 - Cut out the triangle in the center.

S2 :
Generator : S1 & S2

Step 4 - Repeat the steps 2 and 3 on the three black triangles left behind

S3 :

Step 5 - Further repetition with adequate screen resolution will give the following pattern.

Fractal Dimension D = log(N)/log(r)

N=3 (No. of sides in the triangle)

r=2 ( shrink it by factor 2)

= log(3)/log(2)

= 1.585

Process for drawing the Sierpinski gasket

Set corners of triangle :p[0]=(0,0), p[1]=(1,0), p[2]=(.5,1)

Set P to one of these, chosen randomly;

do {

Draw a dot at P;

Choose one of the 3 points at random;

Set newPt to the midpoint of P and the chosen point;

Set P= newPt;

} while(!bored);

Koch Curve

The Koch curve is generated by a simple geometric procedure which can be iterated an infinite
number of times by dividing a straight line into three equal parts and substituting the
intermediate part with two segments of the same length (like Triangular bump)
Construction of Koch curve

Let the successive generations of the Koch curve be K0,K1,K2….

1.Start with a straight line of length 1 be Ko the Initiator

Ko : Initiator

2. The straight line is divided into 3 equal parts, and the middle part is replaced by two linear
segments at angles 60º and 120º be K1 the Generator

K1 : Generator

3.Repeat the steps 2 to the four line segments generated in Step-2

K1 :

4. Further iterations will generate the Koch curves

The fractal dimension is computed using the equation:

  D = log (N) / log (r)

N= 4 segments

r=3 (Shrinking factor)

D = log(4) / log(3) = 1.26185


General Procedure

To form Kn+1 from Kn

Subdivide each segment of Kn into three equal parts and replace the middle part with a bump
in the shape of an equilateral triangle.

Total length of Ki is (4/3)i which increases as i increases.

Pseudocode to draw Kn

if (n equals 0)
draw straight line
else
{
Draw Kn-1
turn left 60 degree
Draw Kn-1
turn right 120 degree
Draw Kn-1
turn left 60 degree
Draw Kn-1
}

OpenGL Code

void drawkoch(GLdouble dir,GLdouble len,GLint n)


{
GLdouble dirrad=(0.0174533)*dir;
GLfloat newx=oldx+len*cos(dirrad);
GLfloat newy=oldy+len*sin(dirrad);
if(n==0)
{
glVertex2f(oldx,oldy);
glVertex2f(newx,newy);
oldx=newx;
oldy=newy;
}
else
{
n--;
len=len/3.0;
drawkoch(dir,len,n);
dir=dir+60.0;
drawkoch(dir,len,n);
dir=dir-120.0;
drawkoch(dir,len,n);
dir=dir+60.0;
drawkoch(dir,len,n);
}}
Quadratic Koch Curve
The segments are refined to eight segments that are 1/4th of the original segment
D = log(8)/log(4) = 1.5

Space-filling fractal
There is a type of fractals continuously attempts to fill in the empty area without any holes as it
goes along its iteration. We call them space-filling fractals.
 Peano Curve
 Hilbert Curve

Hilbert Curve which fill up a square plane, the Peano Curve fills up a plane in rhombus
shape.

The fractal dimension will be always 2.


Peano Curve
The Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe
Peano. The fundamental idea behind a plane filling curve is that a line, a basic  one-dimensional
element, can be contorted and through the principle of self-similar replication, end up filling a
plane, a two dimensional entity. The transition of the Peano curve, from a line to a plane.
Construction of Peano curve

Let the successive generations of the Peano curve be P0,P1,P2….

1.Start with a straight line of length 1 be Po the Initiator

Po : Initiator
2. Divide the line segment into 9 segment in two dimension be P1 the Generator

P1 : Generator

3. As the segments are replicated at higher and higher levels, the curve's  "plane"  filling
properties become increasingly apparent

P2 to Pn :

Fractal Dimension Peano curve


Number of segments N = 9
r=3 (Shrinking factor)
= log(9)/log(3)

=2

Hilbert Curve
The basic principle behind the Hilbert curve is slightly different from the constructions of exact
replacements. Instead of using a single standard shape to replace every line segment on every
continuing level, the Hilbert curve applies various shapes or “rules” to different segments.  The
Hilbert curve forms an elegant construction of patterns whose lines do not overlap. Also, since
the standard Hilbert curve fills a plane, its dimension is 2.
The basic elements of the Hilbert curves are
Cups – (a square with one open side)
The open side of a cup can be top, bottom, left or right
Every cup has two end-points
Joins - (a vector that joins two cups)
A join has a direction : up, down, left or right
Construction of Hilbert curve

Let the successive generations of the Hilbert curve be H0,H1,H2….

1. Start with the basic staple-like shape. Single cup which filles a 2 X 2 space.

Ho : Initiator

2. Replaces that cup by four smaller cups, which are linked together by three joins.
Shrink the previous curve to half its size. Simultaneously, decrease the grid size by
the factor of two.
Place four copies of the curve on the grid. The lower two must be placed directly as they
are.
The upper two must be rotated a quarter turn - one left, another right.
Lastly, connect the four pieces with short straight segments to obtain the next step curve.
Sometimes the connecting segments are horizontal, and sometimes they are vertical
H1: Generator
Cup division rules

3.All the rest of the curves are created sequentially one from another using the same algorithm.

Fractal Dimension for Hilbert Curve


N = 4 (Number of segments)
r=2 (shrinking factor)
D = log(N)/log(r)
D=log(4)/log(2)
D=2
RANDOM FRACTALS

Fractal is the term associated with randomly generated curves and surfaces that
exhibit a degree of self-similarity. These curves are used to provide “naturalistic” shapes for
representing objects such as coastlines, rugged mountains, grass and fire.
Random fractal is generated by stochastic rather than deterministic processes. It can be generated
by modifying the iteration process of the last section to include a probabilistic element.

Fractalizing a Segment

The simplest random fractal is formed by recursively roughening or fractalizing a


line segment. At each step, each line segment is replaced with a “random elbow”.

Generating Random Fractals

Let S be the line segment having endpoints A and B.

Draw a line segment

S is replaced by the two segments from A to C and from C to B.

For a fractal curve, point C is randomly chosen along the perpendicular bisector L of S.

The elbow lies randomly on one or the other side of the “parent” segment AB.

Draw a random fractal

Stages in the fractalization process

Three stages are required in the fractalization of a segment.

In the first stage, the midpoint of AB is perturbed to form point C.

Draw First stage diagram

In the second stage , each of the two segment AC and BC has its midpoints perturbed to form
points D and E.

Draw Second stage diagram

In the third ,AD, DC, CE and EB has its the new points F, G, H and I.

Draw third diagram

Parametric Form

Line L passes through the midpoint M of segment S and is perpendicular to it.


Any point C along L has the parametric form:

C(t) = M + (B-A) t

for some values of t, where the midpoint M= (A+B)/2.


The distance of C from M is |B-A||t|, which is proportional to both t and the length
of S. So to produce a point C on the random elbow, we let t be computed randomly. If t is
positive, the elbow lies to one side of AB; if t is negative it lies to the other side.

Algorithm for Fractalizing a Line segment

void fract(Point2 A, Point2 B, double stdDev)


double xDiff = A.x – B.x, yDiff= A.y –B.y;
Point2 C;
if(xDiff * XDiff + YDiff * yDiff < minLenSq)
cvs.lintTo(B.x, B.y);
else
{
stdDev *=factor;
double t=0;
for(int i=0; I, 12; i++)
t+= rand()/32768.0;
t= (t-6) * stdDev;
C.x = 0.5 *(A.x +B.x) – t * (B.y – A.y);
C.y = 0.5 *(A.y +B.y) – t * (B.x – A.x);
fract(A, C, stdDev);
fract(C, B, stdDev);
}

You might also like