Unit 4 CGA 2021
Unit 4 CGA 2021
Vidyalankar School of
Information Technology
Wadala (E), Mumbai
www.vsit.edu.in
Certificate
This is to certify that the e-book titled “Computer Graphics and
Animation” comprises all elementary learning tools for a better
understating of the relevant concepts. This e-book is comprehensively
compiled as per the predefined eight parameters and guidelines.
Signature
Date: 22-03-2021
Prof. Rohini Desai
Assistant Professor
Department of IT
Contents
Visible-Surface Determination:
Techniques for efficient Visible-Surface Algorithms, Categories of algorithms, Back
face removal, The z-Buffer Algorithm, Scan-line method, Painter’s algorithms (depth
sorting), Area sub-division method, BSP trees, Visible-Surface Ray Tracing,
comparison of the methods.
Plane Curves and Surfaces:
Curve Representation, Nonparametric Curves, Parametric Curves, Parametric
Representation of a Circle, Parametric Representation of an Ellipse, Parametric
Representation of a Parabola, Parametric Representation of a Hyperbola,
Representation of Space Curves, Cubic Splines, , Bezier Curves, B-``spline Curves,
B-spline Curve Fit, B-spline Curve Subdivision, Parametric Cubic Curves, Quadric
Surfaces. Bezier Surfaces.
References:
Sr.
Reference Book Titles Author/s Publisher Edition Module Nos.
No
J. D. Foley, A. Van
Computer Graphics - 2nd
1 Dam, S. K. Feiner Pearson Unit 1
Principles and Practice
and J. F. Hughes
Fundamentals of Computer Steve Marschner, CRC
2 4th Unit 2, 3 & 5
Graphics Peter Shirley Press
2nd
3 Computer Graphics Hearn, Baker Pearson All
William M.
Principles of Interactive 2nd
4 Newman and TMH Unit 5
Computer Graphics
Robert F. Sproull
Mathematical Elements for D. F. Rogers, J. A. 2nd
5 TMH Unit 2 & 3
CG Adams
Basics of Computer
6 Atul.P. Godse Technical 1st Unit 1 & 2
Graphics
Requisites III IV V
Introduction - OOPS - - - Project
Visible-Surface Determination:
Techniques for efficient Visible-surface Algorithms
The techniques to perform visible surface algorithms efficiently are discussed in the following sections.
https://www.youtube.com/watch?v=j7zASv6vUKk&index=21&list=PLG9aCp4uE-s1DbifcNYNPz0w3oR3aZOiV
1. Coherence
The coherence is defined as the degree to which parts of an environment or its projection
exhibit local similarities. Such as similarities in depth, colour, texture and so on. To make
algorithms more efficient we can exploit these similarities when we reuse calculations made
for one part of the environment or a picture for other nearby parts, either without changes
or with some incremental changes. Different kinds of coherence we can use in visible surface
algorithms are.
i. Object coherence: if one object entirely separates from another, comparisons may
need to be done only between the two objects, and not between their components
faces or edges.
ii. Face coherence: Usually surface properties vary smoothly across a face. This allows
the computations for one part of face to be used with incremental changes to the
other parts of the face.
iii. Edge coherence: The visibility of edge may change only when it crosses a visible
edge or penetrates a visible face.
iv. Implied edge coherence: If one planar face penetrates another their line of
intersection can be determined from two points of intersection.
v. Area coherence: A group of adjacent pixels is often belonging to the same visible
face.
vi. Span coherence: It refers to a visibility of face over a span of adjacent pixels on a
scan line. It is special case area coherence.
vii. Scan line coherence: The set of visible object spans determined for one scan line of
an image typically changes very little from the set on the previous line.
viii. Depth coherence: Adjacent parts of the same surface are typically same or very
close depth. Therefore, once the depth at one point of the surface is determined,
the depth of the points on the rest of the surface can be determined by at the
simplest incremental calculation.
ix. Frame coherence: Pictures of the same scene at two successive points in time are
likely to be quite similar, except small changes in object and view ports. Therefore,
the calculations made for one picture can be reused for the next picture in as
sequence.
2. Perspective Transformation
i. Visible-surface determination is done in a 3D space prior to the projection into 2d
that destroys the depth information needed for depth comparisons, and depth
comparisons are typically done after the normalizing transformation.
ii. Due to this projector are parallel to the Z axis in parallel projections or emanate
from the origin in perspective projections.
iii. In parallel projection, when x1=x2 and y1=y2 we can say that points are on the same
projector.
iv. However, in perspective projection we must perform four divisions: x1/z1=x2/z2 and
y1/z1=y2/z2 to determine whether the points are on the same projector.
v. These divisions can be avoided by first transforming a 3D object into the 3D screen-
coordinate systems, so that the parallel projection of the transformed object is the
same as the perspective projection of the untransformed object.
3. Extents and bounding Volumes.
i. Two objects with their projections and the rectangular screen extents surrounding
the projections.
ii. It is easier to check the overlapping of extents than the projections, and we can say
that when we extend are not overlapping then projections are also not overlapping.
Therefore, extents must be compared first and then the projections must be
compared only if the extents are overlapped. This avoids unnecessary comparisons
in checking the overlapping of projections if extents are not overlapped.
iii. Extents can be used to surround the object themselves rather than their projections;
in this case the extent become solid and are commonly known as bounding volumes.
In this case extent can be used to check whether two objects are overlapped or not.
iv. Extent and bounding volumes are used not only to compare two objects or their
projections with each other, but also to determine whether projector intersects an
object.
4. Back-Face Culling
i. When an object is approximated by a solid polyhedron, its polygonal faces
completely enclose its volume. In such case, if none of the polyhedron’s interior is
exposed by the front clipping plane, then those polygons whose surface normal
point away from the observer lie on a part of the polyhedron whose visibility is
completely blocked by other closer polygons.
ii. Polygons (A, B, D, F) in gray are eliminated, whereas front-facing polygon (C, E, G, H)
are retained.
iii. These invisible back facing polygons can be eliminated from further processing. Such
a technique to eliminate the back facing polygon from further processing is known
as Back-face Culling.
5. Spatial Partitioning
i. In this technique, subdivision rule is applied to break down a large problem into a
number of smaller ones. I this object and their projections are assigned to spatically
coherent groups as a pre-processing step. This partitioning speed up the process of
determining which object intersect with a projector. Because now it is necessary to
test only the objects lying within the partitions which intersect with projector.
ii. When objects are unequally distributed in space the adaptive partitioning is more
suitable. Because it allows variable size of each partition.
6. Hierarchy
i. In hierarchical structure different levels are assigned to the object and there is a
parent-child relationship between the objects.
ii. In this structure, each child is considered as a part of its parent. This allows to
restrict the number of object comparison needed by a visible-surface algorithm.
iii. If the parent level object is fail to intersect, the lower level objects belongs to the
parent do not need to be tested for intersection.
Categories of Algorithms
1. A polygon has two surfaces, a front and a back just as a piece of paper does. We
might picture our polygons with one side painted light and the other painted
dark. But the question is “how to find which surface is light or dark”.
2. When we are looking at the light surface, the polygon will appear to be drawn
with counter clockwise pen motions, and when we are looking at the dark
surface the polygon will appear to be drawn with clockwise pen motions.
3. Let us assume that all solid objects are to be constructed out of polygons in such
a way that only the light surfaces are open to the air; the dark faces meet the
material inside the object. This means that when we look at an object face from
the outside, it will appear to be drawn counterclockwise.
4. If a polygon is visible, the light surface should face towards us and the dark
surface should face away from us. Therefore, if the direction of the light face is
pointing towards the viewer, the face is visible, otherwise the face is hidden and
should be removed.
5. The direction of the light face can be identified by examining the result
N.V > 0
Where N: Normal vector to the polygon surface with cartesian
components(A,B,C).
V: A vector in the viewing direction from the eye position.
6. We know that, the dot product of two vector gives the product of the length of
the two vectors times the cosine of the angle between them.
7. This cosine factor is important to us because if the vectors are in the same
direction (0≤Θ<π/2), then the cosine is positive, and the overall dot product is
positive. However, if the direction is opposite (π/2<Θ≤π), then the cosine and the
overall dot product is negative.
8. If the dot product is positive, we can say that the polygon faces towards the
viewer; otherwise it faces away and should be removed.
9. In case, if object description has been converted to projection coordinates and
our viewing direction is parallel to the viewing zv axis, then V=(0, 0, Vz) and
V.N = Vz C
10. So that we only have to consider the sign of C, the Z component of the normal
vector N. Now, if the z component is positive, then the polygon faces towards the
viewer, if negative, it faces away.
https://www.youtube.com/watch?v=5b2eKCMTq-
A&index=22&list=PLG9aCp4uE-s1DbifcNYNPz0w3oR3aZOiV
1. A scan line method of hidden surface removal is another approach of image space method.
It is an extension of the scan line algorithm for filling polygon interiors. Here, the algorithm
deals with more than one surfaces. As each scan line is processed, it examines all polygon
surfaces intersecting that line to determine which are visible. It does the depth calculation
and finds which polygon is nearest to the view plane. Finally, it enters the intensity value of
the nearest value of the nearest polygon at that position into the frame buffer.
2. We know that scan line algorithm maintains the active edge list. This active edge list contains only
edges that cross the current scan line, sorted in order of increasing x. The scan to indicate whether a
position along a scan line is inside or outside of the surface. Scan lines are processed from left to right.
At the leftmost boundary of a surface, the surface flag is turned ON, and at the rightmost boundary, it
is turned OFF.
3. The figure illustrates the scan line method for hidden surface removal. The active edge list for scan
line 1 contains the information for edges AD, BC, EH an FG. For the positions along this scan line
between edges AB and BC, only the flag for surface S1 is ON. Therefore, no depth calculations are
necessary, and intensity information for surface S1 is entered the frame buffer. Similarly, between
edges EH and FG, only the flag for surface S2 is ON and during that portion of scan line intensity
information for surface S2 is entered the frame buffer.
4. For scan line, the active edge list contains edges AD, EH, BC, FG. Along the scan line 2 from edge AD to
edge EH, only the flag for surface S1 is ON. However, between edges EH and BC, the flags for both
surface are ON. In this portion of scan, line 2, the depth calculations are necessary. Here we have
assumed that the depth of S1 is less than the depth of S2 and hence the intensities of surface S1 are
loaded into the frame buffer. Then for edge BC to edge FG portion of scan line 2 intensities of surface
S2 are entered the frame buffer because buffer during that portion only flag for S2 is ON.
Z-Buffer Algorithm
1. One of the simplest and commonly use image space approach to eliminate hidden surface is
the Z-buffer or depth buffer algorithm. It is developed by Catmull. This algorithm compares
surface depths at each pixel position on the projection plane. The surface depth is measured
from the view plane along the z axis of a viewing system. When object description is
converted to projection coordinates (x, y, z), each pixel position on the view plane is
specified by x and y coordinate, and z values gives the depth information. Thus, object
depths can be compared by comparing the z- values.
2. The Z-buffer algorithm is usually implemented in the normalized coordinates, so that z
values range from 0 at the back-clipping plane to 1 at the front clipping plane. The
implementation requires another buffer called Z-buffer along with the frame buffer memory
required for raster display devices. A Z-buffer is used to store depth values for each (x, y)
position as surfaces are processed, and the frame buffer stores the intensity values for each
position. At the beginning the z-value at the back-clipping plane, and the frame buffer is
initialized to the background colour. Each surface listed in the display file is then processed,
one scan line at a time calculating the depth (z-value) at each (x, y) pixel position.
3. The calculated depth value is compared to the value previously stored in the Z-buffer at that
position. If the calculated depth values is greater that the value stored in the Z-buffer, the
new depth value is stored, and the surface intensity at that position is determined and
placed in the same xy location in the frame buffer.
4. For example, among three surfaces, surface S1 has the smallest depth at view position (x, y)
and the highest z value. So, it is visible at that position.
https://www.youtube.com/watch?v=TsjYPu7piY0&index=23&list=PLG9aCp4uE-
s1DbifcNYNPz0w3oR3aZOiV
Algorithm
1. Initialize the Z-buffer and frame buffer so that for all buffer positions Z-buffer (x, y) = 0 and
frame-buffer (x, y) = Ibackground
2. During scan conversion process, for each position on each polygon surface, compare depth
values to previously stored values in the depth buffer to determine visibility. Calculate z-
value for each (x, y) position on the polygon
If z>Z-buffer (x, y) then set Z-buffer (x, y) =z, frame-buffer (x, y) = Isurface (x, y)
3. Stop.
Advantages
1. It is easy to implement
2. It can be implemented in hardware to overcome the speed problem.
3. Since the algorithm processes objects one at a time, the total number of polygons in a
picture can be arbitrarily large.
Disadvantages
1. It requires an additional buffer and hence the large memory.
2. It is time consuming process as it requires comparison for each pixel instead of for the entire
polygon.
Advantages
1. It follows the divide-and-conquer strategy; therefore, parallel computers can be used to
speed up the process.
2. Extra memory buffer is not required.
• Put all the nodes that are in front of root A to the left side of node Aand put all those nodes
that are behind the root A to the right side as shown in figure (b).
• Process all the front nodes first and then the nodes at the back.
• As shown in figure (c), we will first process the node B. As there is nothing in front of the
node B, we have put NIL. However, we have node C at back of node B, so node C will go to
the right side of node B.
• Second, the surfaces are scan-converted in order, starting with the surface of greatest
depth.
• The scan conversion of the polygon surfaces is performed in image space. This method for
solving the hidden-surface problem is often referred to as the painter's algorithm. The
following figure shows the effect of depth sorting −
• The algorithm begins by sorting by depth. For example, the initial “depth” estimate of a
polygon may be taken to be the closest z value of any vertex of the polygon.
• Let us take the polygon P at the end of the list. Consider all polygons Q whose z-extents
overlap P’s. Before drawing P, we make the following tests. If any of the following tests is
positive, then we can assume P can be drawn before Q.
• If all the tests fail, then we split either P or Q using the plane of the other. The new cut
polygons are inserting into the depth order and the process continues. Theoretically, this
partitioning could generate O(n2) individual polygons, but in practice, the number of
polygons is much smaller.
Introduction to Curve
In computer graphics, we often need to draw different types of objects onto the screen. Objects are
not flat all the time and we need to draw curves many times to draw an object.
Types of Curves
A curve is an infinitely large set of points. Each point has two neighbors except endpoints. Curves
can be broadly classified into three categories − explicit, implicit, and parametric curves.
Implicit Curves
Implicit curve representations define the set of points on a curve by employing a procedure that
can test to see if a point in on the curve. Usually, an implicit curve is defined by an implicit function
of the form –
f(x, y) = 0
It can represent multivalued curves (multiple y values for an x value). A common example is the
circle, whose implicit representation is
x2 + y2 - R2 = 0
Explicit Curves
A mathematical function y = f(x) can be plotted as a curve. Such a function is the explicit
representation of the curve. The explicit representation is not general, since it cannot represent
vertical lines and is also single-valued. For each value of x, only a single value of y is normally
computed by the function.
Parametric Curves
Curves having parametric form are called parametric curves. The explicit and implicit curve
representations can be used only when the function is known. In practice the parametric curves are
used. A two-dimensional parametric curve has the following form −
The functions f and g become the (x, y) coordinates of any point on the curve, and the points are
obtained when the parameter t is varied over a certain interval [a, b], normally [0, 1].
when t runs from 0 to 1, the angle argument runs a full circle, and the point (x(t),y(t)) describes a
circle.
2. Parametric Representation of Ellipse
An ellipse can be defined as the locus of all the points that satisfy the equations:
X= acos t y = bsin t
Where x, y are the coordinates of any point on the ellipse, a, b are the radius on the x and y axes
respectively, t is the parameter which ranges from 0 to 2𝜋 radians.
describe the ellipse as (x/rx)2 +(y/ry)2 =1
Parametrically we describe an ellipse like this:
x(t’) = rx . cos(t’)
y(t’) = ry . sin(t’)
0 ≤ t ≤ 2π
3. Parametric Representation of Parabola
Since every parabola is congruent to x2 = 4ay, for some choice of a> o, we can study the geometry of
every parabola by confining ourselves to this one. This shows the power of both coordinate geometry
and transformations. Imagine a particle moving in the plane along the curve C as shown.
The x- and y- coordinate of the particle can be thought of as functions of a new variable t, and so we
can write x=f(t) , y=g(t), where f, g are functions of t. t is time.
The equations x= f(t), y = g(t) are called the parametric equations of the point P(x,y) and the variable t is
called a parameter.
It is often very useful to take a Cartesian equation y= F(x) and introduce a parameter t so that the x and
y – coordinates of any point on the curve can be expressed In terms of this parameter.
4. Parametric Representation of Hyperbola
A hyperbola centred at the origin with a left-right opening has the equation:
(x2/a2) - (y2/b2) =1
In this case, we can use the equations x= a sec t, y= b tan t. This is because if you plug these
expressions in to the above equation, then the equation reduces to the trigonometric identity sec 2 t –
tan2 t =1
Hyperbola centred at the origin with an up-down opening has the equation:
(y2/a2) - (x2/b2) =1
In this case, switch the expressions for x and y, using the equations
X= b tan t, y= a sec t.
If the center of the hyperbola is at (h, k), then the equation is:
((x-h)2/a2) - ((y-k)2/b2) =1 or ((y-k)2/a2) - ((x-h)2/b2) =1
In the first case, the parametric equation x- h _a sec t, y= K + b tan t will work, and in the second case
it will be x-h + b tan t, y=k +a sec t.
Representation of Space Curves
Bezier curve
Bezier curve is discovered by the French engineer Pierre Bézier. These curves can be generated
under the control of other points. Approximate tangents by using control points are used to
generate curve. The Bezier curve can be represented mathematically as −
n∑ n
k=0 PiBi (t)
Where pi is the set of points and Bin(t) represents the Bernstein polynomials which are given by −
Bin(t)= (n i) (1−t)n−t ti
Where n is the polynomial degree, i is the index, and t is the variable.
The simplest Bezier curve is the straight line from the point P0 to P1. A quadratic Bezier curve is
determined by three control points. A cubic Bezier curve is determined by four control points.
https://www.youtube.com/watch?v=9ny-0gdbS94&list=PLG9aCp4uE-
s1DbifcNYNPz0w3oR3aZOiV&index=11
Properties of Bezier Curves
Bezier curves have the following properties −
• They generally follow the shape of the control polygon, which consists of the segments
joining the control points.
• They always pass through the first and last control points.
• They are contained in the convex hull of their defining 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.
• The direction of the tangent vector at the end points is same as that of the vector
determined by first and last segments.
• 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.
• Bezier curves exhibit global control means moving a control point alters the shape of the
whole curve.
• A given Bezier curve can be subdivided at a point t=t0 into two Bezier segments which join
at the point corresponding to the parameter value t=t0.
B-Spline Curves
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.
The B-spline basis contains the Bernstein basis as the special case. The B-spline basis is non-global.
A B-spline curve is defined as a linear combination of control points Pi and B-spline basis
function Ni, k (t) given by Ni, k
C(t)=∑ni=0P, Ni,k (t), n≥k−1, tϵ[tk−1,tn+1]
Where,
• the Ni,k(t) are the “normalized B-spline blending functions”. They are described by the order
k and by a non-decreasing sequence of real numbers normally called the “knot sequence”.
ti: i=0, ... n+K
The Ni, k functions are described as follows −
tϵ [tk−1, tn+1)
https://www.youtube.com/watch?v=QKCxAJsLWxQ&index=13&list=PLG9aCp4uE-
s1DbifcNYNPz0w3oR3aZOiV
• The sum of the B-spline basis functions for any parameter value is 1.
• 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.
• B-spline allows the local control over the curve surface because each vertex affects the
shape of a curve only over a range of parameter values where its associated basis function
is nonzero.
• Any affine transformation can be applied to the curve by applying it to the vertices of
defining polygon.
• The curve line within the convex hull of its defining polygon
B-Spline Curve Subdivision
Subdivision “Subdivision defines a smooth curve or surface as the limit of a sequence of successive
refinements”
The sub division of B- Spline curve used De Boor’s Algorithm. It provides a fast and numerically
stable way for finding a point on a B-spline curve given uint domain. It is the algorithm for evaluating
spline curves in B-spline forms.
Selecting Control Points
Suppose we want to subdivide a B-spline curve at u into two B-spline curves, one on [0,u] and the
other on [u,1]. The first thing to do is to apply de Boor's algorithm at u. Note that if u is in [uk, uk+1),
then at most p+1 control points will be used in the computation, namely: Pk, Pk-1, ..., Pk-p. To find
the control points of the B-spline curve on [0,u], we start with P0 and follow the control polyline.
When we encounter a control point or a point computed in the process of de Boor's algorithm, we
select that point and make a turn. This process continues until we reach C(u) which is also selected
as a control point. These points, in the visiting order, form the control points that define the B-spline
curve on [0,u]. For the B-spline curve defined on [u,1], we start with the point C(u) and apply the
same process. We select each encountered point and make a turn until Pn is reached.
Cubic Curves
Quadratic Surfaces
A second order algebraic surface given by the general equation:
Examples of quadratic surfaces include the cone, cylinder, ellipsoid, elliptic cone, elliptic cylinder,
hyperbolic cylinder, hyperbolic paraboloid, paraboloid, sphere and spheroid.
Bezier surface
Bezier surfaces are a species of mathematical spline used in computer graphics, computer-aided
design, and finite element modeling.
• Bezier surface are an extension of the idea of Bezier curves and share many of their
properties.
• Bezier surface is defined by a set of control points.
• Properties are-
o the surface does not in general pass through the control points (except for the
corner points)
o the surface is contained within the convex hull of the control points.
A two-dimensional Bézier surface can be defined as a parametric surface where the position of a
point p as a function of the parametric coordinates u, v is given by:
• A Bézier surface will transform in the same way as its control points under all linear
transformations and translations.
• All u = constant and v = constant lines in the (u, v) space, and all four edges of the deformed
(u, v) unit square are Bézier curves.
• A Bézier surface will lie completely within the convex hull of its control points, and therefore
also completely within the bounding box of its control points in any given Cartesian coordinate
system.
• The points in the patch corresponding to the corners of the deformed unit square coincide
with four of the control points.
• However, a Bézier surface does not generally pass through its other control points.
Sample Bézier surface; red - control points, blue - control grid, black - surface approximation
Questions:
Q1. Explain Scan-Line Method.
Q2. Write note on Area-Subdivision Method.
Q3. Explain Binary Space Partition (BSP) Trees with example
Q4. Explain Parametric Representation of a Circle, an Ellipse, Parabola and Hyperbola,
Q5. Explain Bezier Curves and surfaces. Write Bezier Curves properties
Q6. What is the concept of Back Face Culling? Explain.
Q7. Explain Painters algorithm.
Q8. Differentiate between Ray Casting and Ray Tracing.
Q9. Define Curve. What are its types? Explain in brief.
Q10. What are the properties of Bezier Curves? Explain.
Q11. Describe the methods used for determination of visible surfaces in rendering.
Q12. Write a short note on Parametric representation of Circle, Ellipse, parabola, hyperbola.
Q13. Explain Scan-line method of an image space.
Q14. Explain techniques for efficient Visible-Surface Algorithms.
a) Type
b) Width
c) Color
b) Horizontal spans
c) Vertical spans
c) Only b
4. If the slope magnitude is 1, then circles, ellipse and other curves will appear
a) Thick
b) Thinnest
c) Big
d) Rough
5. One of the method for displaying thick curves is
a) Curve slope
b) Curve width
c) Curve cap
d) Only c
6. The pixel masks for implementing line-type options are also used in the following algorithm to
generate dashed and dotted patterns.
7. We can generate the dashes in the various octants and the circle path with vertical path using
a) Circles
b) Circle symmetry
c) Circle simmetry
d) Curve slope
d) None of these
d) Neither a nor c
10. The curves displayed with a rectangular pen will be
a) Thinner
d) B or C