Table of Contents (C.
G)
S.N Content Page No
1 Syllabus 2
2 Course Objective and outcomes 3
3 Teaching Pedagogy 4
4 Lesson Plan 5-6
5 Assignments- I&II 7
6 Question Bank 8-9
7 Handouts 10-21
9 Model Test Paper 22
8 Case Studies(If any) N/A
9 Previous Mid/End term question papers Attached
1
BVITSD 402: COMPUTER GRAPHICS
Max Marks :100
Internal Assessment: 30
End Term Examination :70
Duration of Exam : 3 Hours
Unit 1
Graphics Primitives: Introduction to computer graphics, Basics of Graphics systems,
Application areas of Computer Graphics, overview of graphics systems, video-display devices,
and raster-scan systems, random scan systems, graphics monitors .Output Primitives: line
drawing algorithms- DDA and Bresenham's.
Unit 2
2-D Geometrical Transforms: Translation, scaling, rotation, reflection and shear
transformations, matrix representations and homogeneous coordinates, composite transforms,
transformations between coordinate systems.
2-D Viewing: The viewing pipeline, viewing coordinate reference frame, window to view-port
coordinate transformation, viewing functions, Cohen-Sutherland and Cyrusbeck line clipping
algorithms.
Unit 3
3-D Object Representation: Polygon surfaces, quadric surfaces, spline representation, Bezier
curve and B-Spline curves, Bezier and B-Spline surfaces.
Unit 4
3-D Geometric Transformations: Translation, rotation, scaling, reflection and shear
transformations, composite transformations.
3D Projections: Parallel and perspective projections and their classifications.
Unit 5
Basic illumination models, polygon-rendering methods- .Phong and Garoud shading.
SUGGESTED READINGS
1. Donald Hearn and M. Pauline Baker : Computer Graphics, PHI Publications.
2. Plastock : Theory & Problem of Computer Gaphics, Schaum Series.
3. Foley & Van Dam : Fundamentals of Interactive Computer Graphics, Addison-Wesley.
4. Newman : Principles of Interactive Computer Graphics, McGraw Hill.
5. Tosijasu, L.K. : Computer Graphics, Springer-Verleg.
2
Course Objective and Learning outcomes-
On completion of the subject the student learn-
• UNDERSTAND SOME BASIC CONCEPTS OF GRAPHICS AND RELATED TOOLS.
• EXPLAIN THE CORE CONCEPTS OF COMPUTER GRAPHICS, INCLUDING
VIEWING, PROJECTION, PERSPECTIVE, MODELLING AND TRANSFORMATION
IN TWO AND THREE DIMENSIONS
• APPLY THE CONCEPTS OF COLOUR MODELS, LIGHTING AND SHADING
MODELS, TEXTURES, RAY TRACING, HIDDEN SURFACE ELIMINATION, ANTI-
ALIASING, AND RENDERING.
• INTERPRET THE MATHEMATICAL FOUNDATION OF THE CONCEPTS OF
COMPUTER GRAPHICS.
• DESCRIBE THE FUNDAMENTALS OF ANIMATION, PARAMETRIC CURVES AND
SURFACES.
3
Teaching Pedagogy
➢ Every topic will start with their introduction and purpose of it to the
students.
➢ Take some practical examples to explain the concept.
➢ Regular interaction with the students.
➢ As topic is finished. Conduct a class test to all for checking that they are
all well understanding or not the concept.
➢ Computer Laboratory will be provided to students to implement the
concept. More practical session will be there to grab the concept.
➢ Tutorials available on the websites
➢ Discuss all types of questions, end term papers before commencing the
final exam.
➢ Blackboard and LCD will be used to explain and presenting the
graphics image to students.
4
Lesson Plan
Credit: 4
S.N Topic name Hrs
Unit-I
1 Introduction to Graphics 2
2 Video-display devices, and raster-scan systems, random scan 2
systems
3 Graphics monitors 2
4 Primitives: line drawing algorithms- DDA 2
5 Bresenham's.line algorithm (With Practice) 3
Unit-II
1 2-D Geometrical Transforms: Translation, scaling, rotation, 3
reflection and shear transformations.
2 Matrix representations of transformation 1
3 Compositetransforms transformations between coordinate systems. 2
4 2-D Viewing: The viewing pipeline, viewing coordinate reference 2
frame, window to view-port coordinate transformation
5 Cohen-Sutherland and Cyrus beck line clipping algorithms. 2
Unit-III
1 3-D Geometric Transformations: Translation, rotation, scaling, 3
reflection and shear transformations
5
2 Composite transformations 3
3 3D Projections: Parallel and perspective projections and their 2
classifications.
Unit-V
1 Basic illumination models 3
2 polygon-rendering methods- .Phong and Garoud shading 3
Total 35
,.
6
Assignments- I
1. Name the two methods for CRT color displays . Explain them in detail.
2. What are Raster Scan Systems ? State their disadvantages.
3. Describe Random Scan Systems with an appropriate diagram.
4. Using the Bresenham’s Line Drawing algorithm , draw line form (22, 12) and (32,20).
Assignment-II
✓ Explain Reflection and shear transformatoins. Also mention their matrix using
homogeneous coordinate system.
✓ Given a regular rectangular window with (Xmin, Ymin) as (2,4) and (Xmax, Ymax)
as (8,12). Clip a line
A(-1,2) and B( 5, 14) using Cohen Sutherland Line Clipping Algorithm
✓ What do you mean by 3D Projections? Differentiate between Parallel and Perspective
Projections
7
Question Bank
✓ Define Computer Graphics.
✓ Explain any 3 uses of computer graphics applications.
✓ Give an overview of Graphics systems.
✓ What are Video Display Devices. Explain its types in detail.
✓ Name the two methods for CRT color displays . Explain them in detail.
✓ What are Raster Scan Systems ? State their disadvantages.
✓ Describe Random Scan Systems with an appropriate diagram.
✓ What are the advantages of DDA algorithm? What are the disadvantages of DDA
algorithm?
✓ Describe the Bresenham’s algorithm for line drawing.
✓ Write DDA Line Drawing Algorithm. Also Draw a line from (4,4 ) to( 9,9) using
Bresenham’s Line drawing algorithm.
✓ Using the Bresenham’s Line Drawing algorithm , draw line form (22, 12) and (32,20).
✓ Define translation and translation vector.
✓ How is 2D translation applied? Explain with diagram and equation
✓ What is referred to as 2D Rotation & Scaling transformation
✓ Write down the rotation equation and rotation matrix.
✓ Write the matrix representation for scaling, translation and rotation.
✓ Explain window, view port and window - to - view port transformation Give the
equation for window to viewport transformation.
✓ Define viewing transformation. Define view up vector.
✓ What is meant by clipping? Where it happens?
✓ What is point clipping and what are its inequalities?
✓ What is line clipping and what are their parametric representations?
✓ Draw the block diagram for 2D viewing transformation pipeline.
✓ Mention the equation for homogeneous transformation. Explain the reasons behind
implementing the homogenous transformations.
✓ What is known as composition of matrix? Write the composition transformation matrix
for scaling, translation and Rotation.
✓ Why Cohen Sutherland line clipping is popular?
✓ Describe the Cyrus Beck Line clipping algorithm.
✓ Given a Rectangle with Vertices A(5,5), B(15,5), C(15,15) and D( 5,15). Perform the
following transformation on it
✓ Scale the rectangle to its half in Y Direction.
✓ Rotate the Scaled Rectangle with 90 Degrees in Anticlockwise direction
✓ Given a regular rectangular window with (Xmin, Ymin) as (2,4) and (Xmax, Ymax)
as (8,12). Clip a line A(-1,2) and B( 5, 14) using Cohen Sutherland Line Clipping
Algorithm
✓ Given a convex rectangular region with edges (0,0) , (0,4),( 8,0),(8,4). Clip the line
P1P2(-1,1) to (9,3) using Cyrus Beck algorithm.
8
✓ . What are Bezier Curve ? Derive matrix for quadratic Bezier Curve using Bernstein
Polynomial.
✓ A Cubic Bezier Curve is drawn using four control points A(10,10) B( 15,60) C(80,50)
D(70,10). Find any four points lying on the curve.
✓ Explain various properties of Bezier Curves.
✓ Derive Matrix for cubic Bezier curve. Also explain e the limitations of Bezier curves.
✓ Explain various Quadratic Surfaces.
✓ Write a short note on
✓ Polygon Surfaces ii) Spline Representation
✓ Differentiate between Parametric and Geometric Continuity . Explain C0,C1, C2 and 0,G1,
G2.
✓ What is B Spline ? What are its advantages over Bezier Curves? Explain its properties.
✓ . Explain B Spline using cox-de- boor formulae. Differentiate between Uniform , Non
Uniform and Open uniform B Splines.
✓ What do you mean by 3D Projections? Differentiate between Parallel and Perspective
Projections.
✓ What are Parallel projections? Classify it and explain isometric projections.
✓ What is perspective projection? Explain its Classification.
✓ Differentiate between Orthographic, Axonometric and Oblique Projections.
✓ What do you mean by 3 D Transformations. Write matrix for 3D Translation, 3D
Rotation and 3D Scaling.
✓ What do you mean by composite transformations? Explain with example.
✓ Explain Reflection and shear transformatoins. Also mention their matrix using
homogeneous coordinate system.
✓ What do you mean by illumination model. Explain ambient light and Diffuse reflection.
✓ Explain Phong Model of Specular reflection.
✓ Explain steps involved in Phong shading. Differentiate between Phong and Gouraud
shading.
9
Handouts
Bresenham's Line Algorithm
This algorithm is used for scan converting a line. It was developed by Bresenham. It is an
efficient method because it involves only integer addition, subtractions, and multiplication
operations. These operations can be performed very rapidly so lines can be generated
quickly.
In this method, next pixel selected is that one who has the least distance from true line.
The method works as follows:
Assume a pixel P1'(x1',y1'),then select subsequent pixels as we work our may to the night,
one pixel position at a time in the horizontal direction toward P 2'(x2',y2').
Once a pixel in choose at any step
The next pixel is
1. Either the one to its right (lower-bound for the line)
2. One top its right and up (upper-bound for the line)
The line is best approximated by those pixels that fall the least distance from the path
between P1',P2'.
10
To chooses the next one between the bottom pixel S and top pixel T.
If S is chosen
We have xi+1=xi+1 and yi+1=yi
If T is chosen
We have xi+1=xi+1 and yi+1=yi+1
The actual y coordinates of the line at x = xi+1is
y=mxi+1+b
The distance from S to the actual line in y direction
s = y-yi
The distance from T to the actual line in y direction
t = (yi+1)-y
11
Now consider the difference between these 2 distance values
s-t
When (s-t) <0 ⟹ s < t
The closest pixel is S
When (s-t) ≥0 ⟹ s < t
The closest pixel is T
This difference is
s-t = (y-yi)-[(yi+1)-y]
= 2y - 2yi -1
Substituting m by and introducing decision
d
variable i =△x (s-t)
di=△x (2 (xi+1)+2b-2yi-1)
=2△xyi-2△y-1△x.2b-2yi△x-△x
di=2△y.xi-2△x.yi+c
Where c= 2△y+△x (2b-1)
We can write the decision variable di+1 for the next slip on
di+1=2△y.xi+1-2△x.yi+1+c
di+1-di=2△y.(xi+1-xi)- 2△x(yi+1-yi)
Since x_(i+1)=xi+1,we have
di+1+di=2△y.(xi+1-xi)- 2△x(yi+1-yi)
Special Cases
If chosen pixel is at the top pixel T (i.e., di≥0)⟹ yi+1=yi+1
di+1=di+2△y-2△x
If chosen pixel is at the bottom pixel T (i.e., di<0)⟹ yi+1=yi
di+1=di+2△y
Finally, we calculate d1
d1=△x[2m(x1+1)+2b-2y1-1]
d1=△x[2(mx1+b-y1)+2m-1]
12
Since mx1+b-yi=0 and m = , we have
d1=2△y-△x
Advantage:
1. It involves only integer arithmetic, so it is simple.
2. It avoids the generation of duplicate points.
3. It can be implemented using hardware because it does not use multiplication and
division.
4. It is faster as compared to DDA (Digital Differential Analyzer) because it does not involve
floating point calculations like DDA Algorithm.
Disadvantage:
1. This algorithm is meant for basic line drawing only Initializing is not a part of
Bresenham's line algorithm. So to draw smooth lines, you should want to look into a
different algorithm.
Bresenham's Line Algorithm:
Step1: Start Algorithm
Step2: Declare variable x1,x2,y1,y2,d,i1,i2,dx,dy
Step3: Enter value of x1,y1,x2,y2
Where x1,y1are coordinates of starting point
And x2,y2 are coordinates of Ending point
Step4: Calculate dx = x2-x1
Calculate dy = y2-y1
Calculate i1=2*dy
Calculate i2=2*(dy-dx)
Calculate d=i1-dx
Step5: Consider (x, y) as starting point and xendas maximum possible value of x.
If dx < 0
Then x = x2
y = y2
xend=x1
If dx > 0
Then x = x1
y = y1
xend=x2
Step6: Generate point at (x,y)coordinates.
13
Step7: Check if whole line is generated.
If x > = xend
Stop.
Step8: Calculate co-ordinates of the next pixel
If d < 0
Then d = d + i1
If d ≥ 0
Then d = d + i2
Increment y = y + 1
Step9: Increment x = x + 1
Step10: Draw a point of latest (x, y) coordinates
Step11: Go to step 7
Step12: End of Algorithm
Example: Starting and Ending position of the line are (1, 1) and (8, 5). Find intermediate
points.
Solution: x1=1
y1=1
x2=8
y2=5
dx= x2-x1=8-1=7
dy=y2-y1=5-1=4
I1=2* ∆y=2*4=8 I2=2*(∆y-
∆x)=2*(4-7)=-6 d = I1-
∆x=8-7=1
x y d=d+I1 or I2
1 1 d+I2=1+(-6)=-5
2 2 d+I1=-5+8=3
3 2 d+I2=3+(-6)=-3
4 3 d+I1=-3+8=5
5 3 d+I2=5+(-6)=-1
6 4 d+I1=-1+8=7
14
7 4 d+I2=7+(-6)=1
8 5
Program to implement Bresenham's Line Drawing Algorithm:
1. #include<stdio.h>
2. #include<graphics.h>
3. void drawline(int x0, int y0, int x1, int y1)
4. {
5. int dx, dy, p, x, y;
6. dx=x1-x0;
7. dy=y1-y0;
8. x=x0;
9. y=y0;
10. p=2*dy-dx;
11. while(x<x1)
12. {
13. if(p>=0)
14. {
15. putpixel(x,y,7);
16. y=y+1;
15
17. p=p+2*dy-2*dx;
18. }
19. else
20. {
21. putpixel(x,y,7);
22. p=p+2*dy;}
23. x=x+1;
24. }
25. }
26. int main()
27. {
28. int gdriver=DETECT, gmode, error, x0, y0, x1, y1;
29. initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
30. printf("Enter co-ordinates of first point: ");
31. scanf("%d%d", &x0, &y0);
32. printf("Enter co-ordinates of second point: ");
33. scanf("%d%d", &x1, &y1);
34. drawline(x0, y0, x1, y1);
35. return 0;
36. }
Three Dimensional Transformations
The geometric transformations play a vital role in generating images of three Dimensional
objects with the help of these transformations. The location of objects relative to others can
be easily expressed. Sometimes viewpoint changes rapidly, or sometimes objects move in
relation to each other. For this number of transformation can be carried out repeatedly.
Translation
It is the movement of an object from one position to another position. Translation is done
using translation vectors. There are three vectors in 3D instead of two. These vectors are in
x, y, and z directions. Translation in the x-direction is represented using T x. The translation
is y-direction is represented using Ty. The translation in the z- direction is represented using
Tz .
If P is a point having co-ordinates in three directions (x, y, z) is translated, then after
translation its coordinates will be (x1 y1 z1) after translation. Tx Ty Tz are translation
vectors in x, y, and z directions respectively.
x1=x+
Tx
y1=y+Ty
z1=z+
16
Tz
17
Three-dimensional transformations are performed by transforming each vertex of the
object. If an object has five corners, then the translation will be accomplished by translating
all five points to new locations. Following figure 1 shows the translation of point figure 2
shows the translation of the cube.
Matrix for translation
18
Matrix representation of point translation
Point shown in fig is (x, y, z). It become (x1,y1,z1) after translation. Tx Ty Tz are translation
vector.
Example: A point has coordinates in the x, y, z direction i.e., (5, 6, 7). The translation is
done in the x-direction by 3 coordinate and y direction. Three coordinates and in the z-
direction by two coordinates. Shift the object. Find coordinates of the new position.
Solution: Co-ordinate of the point are (5, 6, 7)
Translation vector in x direction = 3
Translation vector in y direction = 3
Translation vector in z direction = 2
Translation matrix is
Multiply co-ordinates of point with translation matrix
= [5+0+0+30+6+0+30+0+7+20+0+0+1] = [8991]
19
x becomes x1=8
y becomes y1=9
z becomes z1=9
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 −
fx,yx,y = 0
It can represent multivalued
curves multipleyvaluesforanxvaluemultipleyvaluesforanxvalue. A
common example is the circle, whose implicit representation is
x 2 + y 2 - R2 = 0
Explicit Curves
A mathematical function y = f xx 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
–
Ptt = ftt, gtt or Ptt = xtt, ytt
The functions f and g become the x,yx,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].
20
Bezier Curves
21
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 −
∑k=0nPiBni(t)∑k=0nPiBin(t)
Where pipi is the set of points and Bni(t)Bin(t) represents the Bernstein
polynomials which are given by −
Bni(t)=(ni)(1−t)n−itiBin(t)=(ni)(1−t)n−iti
Where n is the polynomial degree, i is the index, and t is the variable.
The simplest Bézier curve is the straight line from the point P0P0 to P1P1. A
quadratic Bezier curve is determined by three control points. A cubic Bezier
curve is determined by four control points.
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.
• A Bezier curve generally follows the shape of the defining polygon.
• 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.
• They are invariant under an affine transformation.
• 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 together 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.
22
• 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.
Properties of B-spline Curve
B-spline curves have the following properties −
• 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.
• 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.
• The curve exhibits the variation diminishing property.
• The curve generally follows the shape of defining polygon.
• 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.
23
Model Test paper
Attempt at least one question from
each unit. Unit-I
Q1(a) Name the two methods for CRT color displays . Explain them in detail.
(b) What are Raster Scan Systems ? State their disadvantages
Or
Q2(a) Write DDA Line Drawing Algorithm.
(b) Describe the Bresenham’s algorithm for line
drawing. Unit-II
Q3 Write the matrix representation for scaling, translation and
rotation Or
Q4 Explain window, view port and window - to - view port transformation Give the equation for
window to viewport transformation
Unit-III
✓ Q5 Why Cohen Sutherland line clipping is
popular? Describe the Cyrus Beck Line clipping
algorithm
Or
✓ Q6 What is known as composition of matrix? Write the composition transformation matrix for
scaling, translation and Rotation.
Unit-IV
✓ Q7 A Cubic Bezier Curve is drawn using four control points A(10,10) B( 15,60) C(80,50)
D(70,10). Find any four points lying on the curve.
Or
Q8 What are Bezier Curve ? Derive matrix for quadratic Bezier Curve using Bernstein
Polynomial. Unit-V
Q9 What are Parallel projections? Classify it and explain isometric projections.
What is perspective projection? Explain its Classification
OR
Q10 What do you mean by illumination model. Explain ambient light and Diffuse reflection
24
25