0% found this document useful (0 votes)
38 views31 pages

Unit 5

Uploaded by

yedegog697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views31 pages

Unit 5

Uploaded by

yedegog697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Unit V – Curves and Fractals

Syllabus
06 Hours
• Curves: Introduction, Interpolation and
Approximation, Blending function, B-Spline curve,
Bezier curve
• Fractals: Introduction, Classification, Fractal
generation: snowflake, Triadic curve, Hilbert curve,
Applications.

Aarati Gangshetty
Introduction

• A curve is an infinitely large set of points. Each point has two


neighbors except endpoints in specific direction
• Drawing & manipulating straight lines is easy with simple
math
• In real world however, we also need to consider curved lines
• The hood of a car, airplane wing, path of a rocket.
• So, if we want to model these values we should be able to
represent these mathematically
Curve Generation
Curve Generation

Curve Gen algo With small line seg


(DDA) (Interpolation Technique)
True Curve Approximation

Department of Computer
Computer Graphics 3
Engineering
DDA algorithm for curve generation(True curve)

• uses the differential Equation of curve.


• The Equation for an arc in the angle parameters can be gives as
x=R cosϴ+ x0 ….(1.1)
y=R sinϴ+ y1
where (x0,y0) is the center of curvature and R is the Radius of arc

dx = -R sinϴ dϴ
dy = R cosϴ dϴ ….(1.2)

From Equation we can solve for R cosϴ and R sinϴ as follows.

x = R cosϴ = x0
∴ R cos ϴ =x - x0 and
DDA algorithm for curve generation(True curve)

R sin ϴ =y -y0 …..(1.3)


substituting values of R cos ϴ and R sin ϴ from equation 1.3 in Equation 1.2 we
get,
dx = -(y-y0)dϴ and
dx = (x-x0)dϴ
the valuse of dx and dy indicates the increment in x and y increment, respectively,
to be
x2 = x1 + dx= x1-(y1-y0)dϴ
y2 = y1 + dy = y1 + (x2- x0)dϴ ……(1.5)
• The equation 1.5 forms the basis for arc generation algorithm.
• Usually, the value of dϴ can be determined from the following Equation.
dϴ =Min (0.01,1/(3.2*(|x -x0| + |y -y0|)))
DDA algorithm for curve generation(True
curve)
• ALOGORITHM :
1. Read the center of a curvature,say (x0,y0)
2. Read the arc angle,say ϴ
3. Read the Starting point of the arc,say(x,y)
4. Calculate dϴ
dϴ =Min (0.01,1/(3.2*(|x -x0| + |y -y0|)))
5. Initialize Angle = 0
6. while (Angle < ϴ)
do {
plot(x,y)
x= x-(y-y0) * dϴ
y = y +(x-x0) * dϴ
Angle = Angle + dϴ
}
7. Stop
Problems with DDA algorithm
• We need more information than the end points
• Transformations difficult. Circle  ellipse coz of scaling
• Clipping. New algorithm will have to be developed
• Not all curved have simple generation algorithm
• We need additional patching / approximation technique to fill
gaps. So, why not approximate the entire curve
Approximation / Interpolation and
Blending Technique
• Interpolation - all points of the basic figure are located on the
created figure called interpolation curve segment
• Approximation - all points of the basic figure need not be
located on the created figure called approximation curve
segment.
• Array of sample points
• Close enough to a actual curve
• We can use many function forms which can be made to pass
through
Approximation / Interpolation Technique
Unknown curve

Known sample points

Fit a region with known


curve

Calculate more sample


Points from known curve

Actually draw straight


Line seg connecting points

Department of Computer
Computer Graphics 9
Engineering
Approximation / Interpolation Technique
• Some curves need to be drawn with approximation technique only
as they are complicated & have no direct math function
• Sample points -> Try fitting a known curve -> Calculate more points -
> draw curve by drawing small line segment.
• The main task is finding suitable math function for the known curve
• There are polynomial, exponential & other classes of fucntions
• Polynomial function in parametric form is preferred,
• x = fx(u); y = fy(u); z = fz(u);
• Treats all the 3 directions equally
• Curves which cross themselves can also be drawn easily
Bezier Curve
• Discovered by Pierre Bézier
• Approach for constructing a curve.
• Bezier Curve is parametric curve defined by a set of control points.
• Two points are ends of the curve.
• Other points determine the shape of the curve.
• Useful, convenient, easy to implement, widely used in various CAD
systems.
• Cubic Bezier widely used & most of the shapes can be drawn with it
and it avoids large calculations.
p1

p1 p3

p0 p0
p2
Linear Cubic
Properties of Bezier Curves
• The basic functions are real.
• They always pass through the first and last control points.
• The degree of the polynomial defining the curve segment is one less
that the number of defining polygon point. Therefore, for 4 control
points, the degree of the polynomial is 3, i.e. cubic
polynomial(Degree = Number of Control Points – 1).
• A Bezier curve generally follows the shape of the defining polygon.
• The convex hull property for a Bezier curve ensures that the
polynomial smoothly follows the control points.
• No straight line intersects a Bezier curve more times than it
intersects its control polygon.
• They are invariant under an affine transformation.
Limitations of Bezier curve
• The Bezier-curve produced by the Bernstein
basis function has limited flexibility.
• First, the number of specified polygon vertices
fixes the order of the resulting polynomial
which defines the curve.
• The second limiting characteristic is that the
value of the blending function is nonzero for
all parameter values over the entire curve.
B-Spline Curves
• The B-spline basis contains the Bernstein basis as the special case.
The B-spline basis is non-global.
• Degree of the resulting curve is independent on the no. of
vertices.
• A B-spline curve is defined as a linear combination of control
points Pi and B-spline basis function Ni, k t given by

• C(t)=∑ni=PiNi,k(t), n≥k−1, tϵ[tk−1,tn+1]


where, {pi: i=0, 1, 2….n} are the control points
• k is the order of the polynomial segments of the B-spline
curve
• Ni,k(t) - “normalized B-spline blending functions”
Knots in B-spline Curve
• The point between two segments of a curve that joins each
other such points are known as knots in B-spline curve.
• These knot vectors could be of three types –
i. Uniform (periodic): Individual values are evenly spaced e.g.
[0,1,2,3]
ii. Open-Uniform: Internal knot values are evenly spaced. E.g.
K=2[001233]
K=3[00012333]
Properties of B-spline Curve
• The sum of the B-spline basis functions for any parameter value is 1.
• Each basis function is positive or zero for all parameter values.
• Each basis function has precisely one maximum value, except for
k=1.
• The maximum order of the curve is equal to the number of vertices
of defining polygon.
• The degree of B-spline polynomial is independent on the number of
vertices of defining polygon.
• The curve exhibits the variation diminishing property.
• The curve generally follows the shape of defining polygon.
• The curve line within the convex hull of its defining polygon.
Fractals
• Fractals are very complex pictures generated by a computer from a
single formula.
• Rough, jagged and random surfaces are called as fractals
• Basic principle is get the end points, divide into parts and draw these
parts including some random function.
Ex:
• Mountain,Branches of trees,
• animal circulatory systems,
• snowflakes, lightning and electricity
• plants leaves
• geographic terrain and river systems
• clouds
• crystals.
Fractals are used in many areas
• Astronomy − For analyzing galaxies, rings of Saturn, etc.
• Biology/Chemistry − For depicting bacteria cultures, Chemical
reactions, human anatomy, molecules, plants,
• Others − For depicting clouds, coastline and borderlines, data
compression, diffusion, economy, fractal art, fractal music,
landscapes, special effect, etc.
Classification of Fractals
• Self Similar :
– Scaled down versions of the entire object
– Objects subparts are constructed
– Used to model trees, shrubs, plants
• Self-affine:
– Parts formed with different scaling parameters Sx, Sy & Sz in different
coordinate directions
– Random variations are also possible
– Used to model water, clouds
• Invarient:
– Nonlinear transformations are used
– Self squaring fractals

Computer Graphics
Topological Dimension

• Imagine object formed from clay or elastic


• If object deforms into a line, we assign Dt = 1
• If object deforms into a plane/ half plane / disk,
Dt = 2
• If object deforms into space / half-space / sphere,
Dt = 3
• This Dt is called as the topological dimension

Department of Computer
Computer Graphics 20
Engineering
Fractal Dimension

• Suppose we have a line of length L & is divided into N


identical parts of length l. Then l can be given as,
• l=L/N
• Each piece looks like the original, only scaled by a
factor of 1/S
• To assemble the original line segment from the
segments scaled by 1/S, we must add together N =
S1 of them
• Here, N = 21 = 2
L
l l
Fractal Dimension

• Lets consider a square


• If we scale it down by 1/S, we will get a small square
• How many small squares does it take to rebuild the
original?
• In case of S = 2, it takes 4 squares and for S = 3, it
takes 9
• So, in general, N = S2
Fractal Dimension

• Lets consider a cube


• If we scale it down by 1/S, we find that the number
of small cubes needed to assemble a large cube is N
= S3
Fractal Dimension

• If we scale an object by S and must assemble N of


them to reconstruct the full-sized object, then the
dimension D of the object is given by the relation
• N = SD
• D is the fractal dimension. Solving it for D,
• D = log N / log S
• Note: Point sets, curves and surfaces which give a
fractal dimension that is greater than their
topological dimension are called fractals
Hilbert Curve
• The Hilbert curve(H.C) is a space filling curve that visits every
point in a square grid with a size of 2×2, 4×4, 8×8, 16×16, or
any other power of 2.
• It was first described by David Hilbert in 1892.
• If a sq. is divided into four quadrants we can draw the first
approximation to the H.C by connecting centre points of each
quadrant .
Hilbert’s Curve
Hilbert Curve Applications

• The range of IP addresses used by computers can be mapped into


picture.
• Hilbert functions can help build indexes for spatial databases; when
searching for a record in close geographic location they can help
determine the priority for exploring.
• Outside of database work, they are sometimes used in image
process. When converting an image to gray scale through the
dithering of black and white pixels, carry-over values from
thresholding can be carried forward and, by the use of a Hilbert
Curve, the excess can be distributed in a pattern less obvious to the
eye.
• At higher dimensions they can be used to implement task
scheduling in parallel processing computing applications.
Converting multidimensional task allocation into a one dimensional
space and assigning related tasks to locations with higher levels of
proximity.
Koch snowflake Curve
• The Koch snowflake (also known as the Koch curve,
Koch star, or Koch island) is a mathematical curve.
• The Koch curve can be drawn by dividing line into 4
equal segments with scaling factor 1/3.
• Middle two segments are so adjusted that they form
adjacent sides of a triangle.
Koch Curve or Koch Snowflake

Step1:
• Draw an equilateral triangle.
Step2:
• Divide each side in three equal parts.
Step3:
• Draw an equilateral triangle on each middle part. Measure
the length of the middle third to know the length of the sides
of these new triangles.
Koch Curve or Koch Snowflake

Step4:
• Divide each outer side into thirds. You can see the 2nd
generation of triangles covers a bit of the first. These three
line segments shouldn’t be parted in three.
• Step5:
• Draw an equilateral triangle on each middle part.
• Note how you draw each next generation of parts that are
one 3rd of the mast one.
Koch Curve
Pseudocode, to draw Kn:
If (n equals 0) draw straight line
Else{
Draw Kn-1
Turn left 60°
Draw Kn-1
Turn right 120°
Draw Kn-1
Turn left 60°
Draw Kn-1
}

You might also like