DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
CS6513 - COMPUTER GRAPHICS LABORATORY
--- Content provided by FirstRanker.com ---
V SEMESTER - R 2013
LABORATORY MANUAL
Name : ____________________________________
Register No. : ____________________________________
Section : ____________________________________
--- Content provided by FirstRanker.com ---
VISION
College of Engineering is committed to provide highly disciplined, conscientious and enterprising professionals conforming to global standards through value based quality education and training.
MISSION
- To provide competent technical manpower capable of meeting requirements of the industry
- To contribute to the promotion of Academic Excellence in pursuit of Technical Education at different levels
- To train the students to sell his brawn and brain to the highest bidder but to never put a price tag on heart and soul
--- Content provided by FirstRanker.com ---
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
VISION
To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through quality education and to provide enthusiastic professionals with commitment
MISSION
--- Content provided by FirstRanker.com ---
- To educate the students with the state-of-art technologies to meet the growing challenges of the electronics industry
- To carry out research through continuous interaction with research institutes and industry, on advances in communication systems
- To provide the students with strong ground rules to facilitate them for systematic learning, innovation and ethical practices
PROGRAMME EDUCATIONAL OBJECTIVES (PEOS)
- Fundamentals
To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering that will would them to be successful professionals
--- Content provided by FirstRanker.com ---
- Core Competence
To provide students with sound knowledge in engineering and experimental skills to identify complex software problems in industry and to develop practical solution for them
- Breadth
To provide relevant training and experience to bridge the gap between theory and practice this enables to find solutions for real time problem in industry and organization and to design products requiring interdisciplinary skills
- Professionalism skills
To bestow students with adequate training and provide opportunities to work as team that will build up their communication skills, individual leadership and supportive qualities and to develop them to adapt and work in ever changing technologies
- Lifelong Learning
To develop the ability of students to establish themselves as professionals in Computer Science and Engineering and to create awareness about the need for lifelong learning and pursuing advanced degrees
--- Content provided by FirstRanker.com ---
PROGRAMME OUTCOMES (POS)
--- Content provided by FirstRanker.com ---
- To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and Engineering field
- To design and conduct experiments as well as to analyze and interpret and apply the same in the career
- To design and develop innovative and creative software applications
- To understand a complex real world problems and develop an efficient practical solutions
- To create, select and apply appropriate technique, resources, modern engineering and IT tools
- To understand their roles as professionals and give the best to the society
- To develop a system that will meet expected need with realistic constraints such as economical, environmental, social, political, ethical, safe and sustainable
- To communicate effectively and make others understand exactly what they are trying to convey in both verbal and written forms
- To engage lifelong learning and exhibit their technical skills
- To develop and manage projects in multidisciplinary environments
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
CS6513-COMPUTER GRAPHICS LABORATORY
SYLLABUS
COURSE OBJECTIVES
- Understand graphics programming.
- Be exposed to creation of 3D graphical scenes using open graphics library suits.
- Be familiar with image manipulation, enhancement.
- Learn to create animations.
- To create a multimedia presentation/game/project
--- Content provided by FirstRanker.com ---
LIST OF EXPERIMENTS:
- Implementation of algorithms for drawing 2D primitives – Line (DDA, Bresenham's) – all slopes circle (midpoint).
- 2D geometric transformations – translation, rotation, scaling, reflection, shear, window to viewport.
- Composite 2D transformations.
- Line clipping.
- 3D transformations - translation, rotation, scaling.
- 3D projections – parallel, perspective.
- Creating 3D scenes.
- Image editing and manipulation - basic operations on image using any image editing software.
- Creating gif animated images, image optimization
- 2D Animation - to create Interactive animation using any authoring tool
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
COURSE OUTCOMES
--- Content provided by FirstRanker.com ---
- Create 3D graphical scenes using open graphics library suits.
- Implement image manipulation and enhancement.
- Create 2D animations using tools.
CS6513-COMPUTER GRAPHICS LABORATORY
CONTENTS
--- Content provided by FirstRanker.com ---
Sl. No. | Name of the Experiment | Page No. |
---|---|---|
CYCLE 1 - EXPERIMENTS | ||
A | Implementation of Algorithms for drawing 2D Primitives | |
1 | Implementation of DDA line drawing algorithm | 7 |
2 | Implementation of Bresenham's line drawing algorithm | 9 |
3 | Implementation of Bresenham's circle drawing algorithm | 11 |
B | 2D Geometric Transformations | |
4 | Implementation of two dimensional basic transformations – Translation, Rotation, Scaling | 14 |
5 | Implementation of two dimensional transformations – Reflection and Shear | 19 |
6 | Implementation of window – to – viewport mapping | 23 |
7 | Implementation of composite 2D transformations | 26 |
8 | Implementation of Cohen Sutherland line clipping algorithm | 30 |
9 | Implementation of Three Dimensional Transformations - Translation, Rotation, Scaling | 33 |
10 | Implementation of 3D image projections | 36 |
11 | Creation of 3D scenes | 40 |
CYCLE 2 – EXPERIMENTS | ||
C | Image Editing and Manipulation | |
12. | Implementation of basic operations on image using Photoshop | 43 |
13. | Creation of gif animated images | 45 |
14 | Optimizing an image | 47 |
15 | Create a 2D interactive animation using Flash | 55 |
ADDITIONAL EXPERIMENTS BEYOND THE SYLLABUS | ||
16 | Generate a 2D image and add motion to it using C | 58 |
17 | Implementation of Bresenham's ellipse drawing algorithm | 61 |
18 | Implementation of line, circle and ellipse attributes | 63 |
19 | Implementation of Sutherland Hodgeman polygon clipping algorithm | 66 |
Expt. No. 1
IMPLEMENTATION OF ALGORITHMS FOR DRAWING 2D PRIMITIVES
LINE DRAWING USING DDA ALGORITHM
Aim:
To write a C program to draw a line using DDA algorithm
--- Content provided by FirstRanker.com ---
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
Algorithm:
--- Content provided by FirstRanker.com ---
- Start the program.
- Read the starting and ending coordinates xa, ya, xb, and yb,
- Find the x-coordinate difference and y-coordinate difference
- Compare the difference and decide the step value
- Find the increment values of coordinates
- Display the starting point using the function putpixel(xa,ya,4),
- Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,
- Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,
- Stop the program.
dx = xb - xa & dy = yb – ya,
--- Content provided by FirstRanker.com ---
if (dx > dy) step = dx
else
step = dy,
xi = dx / step
--- Content provided by FirstRanker.com ---
yi = dy / step,
--- Content provided by FirstRanker.com ---
Sample Output:
Enter the starting coordinates: 100 100
Enter the ending coordinates: 200 200
Fig.No 1 Line using DDA
Result:
--- Content provided by FirstRanker.com ---
Thus the line was drawn successfully using DDA algorithm in C.
Outcome:
Thus the outcome of implementing 2D primitives has been attained.
Application:
- Image processing
- Computer art
- Presentation graphics
--- Content provided by FirstRanker.com ---
Viva-voce
- What are the advantages of DDA algorithm?
- Define - Computer Graphics
- What are the properties of video display devices?
- What are the various applications of computer graphics?
- What is resolution?
- What is a bitmap?
- List out the important characteristics of video display device.
- What is meant by pixel?
- What is intensity?
- Define – DDA Algorithm
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 2
LINE DRAWING USING BRESENHAM'S ALGORITHM
--- Content provided by FirstRanker.com ---
Aim:
To write a program in C to draw a line using Bresenham's algorithm
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
--- Content provided by FirstRanker.com ---
Dual core processor, DDR2 1GB RAM, 250 GB HDD
Algorithm:
- Start the program.
- Read the starting and ending coordinates xa, ya, xb, yb,
- Find the x-coordinate difference and y-difference
- Calculate decision parameter 'p' value
- Fix the starting and ending coordinates
- Display the starting point using the function putpixel(xa,ya,4),
- Find adjacent pixels and display it using the formula given below
- Repeat the step 7 till reaching the end points,
- Stop the program.
--- Content provided by FirstRanker.com ---
dx = xb - xa & dy = yb – ya,
p = 2dy-dx,
if(xa < xb)
--- Content provided by FirstRanker.com ---
xstart = xa ystart = ya xend = xb
yend = yb
else
xstart = xb
ystart = yb
--- Content provided by FirstRanker.com ---
xend = xa
yend = ya,
x =xstart & y=ystart
--- Content provided by FirstRanker.com ---
while(x < xend)
x = x + 1
if(p < 0)
--- Content provided by FirstRanker.com ---
Sample Output:
Enter the xa & ya value: 200 200
Enter the xb & yb value: 350 45
Fig.No 2 Line using Bresenham's
Result:
--- Content provided by FirstRanker.com ---
Thus a line is drawn successfully using Bresenham's algorithm in C
Outcome:
Thus the outcome of implementing 2D primitives has been attained.
Application:
- Image processing
- Computer art
- Presentation graphics
--- Content provided by FirstRanker.com ---
Viva-voce
- What is the property that reduces the pixel calculation in Bresenham's circle drawing algorithm?
- What is the equation used to find decision parameter in Bresenham's line drawing algorithm?
- What is meant by rasterization?
- List out the advantages and disadvantages of DVST.
- What are the two techniques for producing color displays with a CRT?
- What is vertical retrace of the electron beam?
- What is meant by frame buffer?
- Distinguish between track ball and space ball.
- Define - Digitizers
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 3
CIRCLE DRAWING USING BRESENHAM'S CIRCLE ALGORITHM
Aim:
--- Content provided by FirstRanker.com ---
To draw a circle using Bresenham's circle drawing algorithm in C
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
--- Content provided by FirstRanker.com ---
Algorithm:
- Start the program.
- Get the radius and center of the circle r, xc, yc,
- Obtain the first point on the circumference of a circle centered on the origin as (Xo, Yo) = (0, r),
- Calculate the initial value of the decision parameter as p = 5/4 – r,
- At each xk position, starting at k=0, perform the following test if(pk < 0),
- Determine symmetry points in other seven octants,
- Move each calculated pixel position (x, y) onto the circular path centered on (xc, yc) and plot the coordinat values x = x + xc & y = y + yc,
- Repeat the steps 5 to 7 until x >=
- Stop the program.
--- Content provided by FirstRanker.com ---
the next point along the circle centered on (0,0) is (xk+1, yk+1) and pk+1 = pk + 2xk+1 + 1
Otherwise the next point along the circle is (xk+1, yk-1) and Pk+1 = pk + 2xk+1 + 1 - 2yk+1,where 2xk+1_= 2xk+2 and = -2.
--- Content provided by FirstRanker.com ---
Sample Output:
Enter the xa value: 200
Enter the ya value: 200
--- Content provided by FirstRanker.com ---
Enter the radius: 50
Fig.No 3 Circle using Bresenham's
Result:
Thus the circle was drawn successfully using Bresenham's circle drawing algorithm in C.
Outcome:
--- Content provided by FirstRanker.com ---
Thus the outcome of implementing 2D primitives has been attained.
Application:
- Image processing
- Computer art
- Presentation graphics
--- Content provided by FirstRanker.com ---
Viva-voce
- What are the two basic techniques for producing color display with a CRT?
- Give three difference between shadows mask and beam penetration method.
- Differentiate LCD from LED.
- Differentiate plasma panel display from thin film electroluminescent display.
- Define – Bresenham's Circle Algorithm
--- Content provided by FirstRanker.com ---
Expt. No. 4
2D GEOMETRIC TRANSFORMATIONS
BASIC 2D TRANSFORMATIONS – TRANSLATION, ROTATION, SCALING
Aim:
--- Content provided by FirstRanker.com ---
To write a program to perform the basic 2D transformations like translation, rotation and scaling using transformation equation in C
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
--- Content provided by FirstRanker.com ---
Algorithm:
- Start the program.
- Obtain the coordinates of the line xa, ya, xb, yb,
- Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,
- Find the translated coordinates by applying the angle as
- Get the rotation coordinates by applying the angle as
- Scaling is applied as
- Draw the transformed line with the new coordinates (x', y'),
- Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the basic transformations,
- Stop the program.
--- Content provided by FirstRanker.com ---
x' = x + tx & y'= y + ty.
x' = abs(xa - xb) cosa - abs(ya - yb) sina
y' = abs(xa - xb) sina + abs(ya - yb) cosa,
--- Content provided by FirstRanker.com ---
x = x * SX
y' = y * sy,
--- Content provided by FirstRanker.com ---
Sample Output:
Line
1. Translation 2. Scaling 3. Rotation 4. Exit
Enter the choice: 1
Enter the x1 value: 100
--- Content provided by FirstRanker.com ---
Enter the y1 value: 100
Enter the x2 value: 200
Enter the y2 value: 200
Enter the translation factor in x-axis: 50
Enter the translation factor in y-axis: 0
--- Content provided by FirstRanker.com ---
Fig.No 4.0 Translation
1. Translation 2. Scaling 3. Rotation 4. Exit
Enter the choice: 2
Enter the x1 value: 100
Enter the y1 value: 100
--- Content provided by FirstRanker.com ---
Enter the x2 value: 200
Enter the y2 value: 200
Enter the scaling factor in x-axis: 1
Enter the scaling factor in y-axis: 2
Fig.No 4.1 Scaling
--- Content provided by FirstRanker.com ---
1. Translation 2. Scaling 3. Rotation 4. Exit
Enter the choice: 3
Enter the x1 value: 100
Enter the y1 value: 100
Enter the x2 value: 200
--- Content provided by FirstRanker.com ---
Enter the y2 value: 200
Enter the rotation angle: 45
Fig.No 4.2 Rotation
Result:
Thus the program for performing basic 2D transformations using transformation equation is successfully executed in C.
--- Content provided by FirstRanker.com ---
Outcome:
Thus the outcome of implementing 2D geometric transformation has been met.
Application:
- Used in traditional printing
- Drawing technologies
--- Content provided by FirstRanker.com ---
Viva-voce
- What are the changes accomplished by adding attributes?
- Which transformation produces a mirror image of an object?
- Which is not a basic transformation operation?
- What is transformation?
- What is a view plane?
- What are the steps involved in 3D transformation pipeline?
- What is fixed point scaling?
- Distinguish between uniform scaling and differential scaling.
- What are the different kinds of co-ordinate representation?
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 5
2D TANSFORMATIONS (REFLECTION AND SHEARING)
Aim:
To write a program to perform the other 2D transformations like reflection and shearing in C
Software requirements:
--- Content provided by FirstRanker.com ---
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
Algorithm:
- Start the program.
- For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,
- Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),
- For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,
- Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,
- Draw the transformed objects with the new coordinates (x`, y`),
- Stop the program.
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Sample Output:
1. Reflection 2. Shearing 3. Exit
Enter the choice: 1
Enter the xa&ya value: 200 100
--- Content provided by FirstRanker.com ---
Enter the xb&yb value: 200 200
Enter the xc&yc value: 100 200
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 1
Fig.No 5.0 Reflection about x-axis
--- Content provided by FirstRanker.com ---
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 2
Fig.No 5.1 Reflection about y-axis
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 3
--- Content provided by FirstRanker.com ---
Fig.No 5.2 Reflection on both
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 4
1. Reflection 2. Shearing 3. Exit
Enter the choice: 2
--- Content provided by FirstRanker.com ---
Enter the xa&ya value: 200 200
Enter the xb&yb value: 300 200
Enter the xc&yc value: 300 300
Enter the xd&yd value: 200 300
1. About x-axis 2. About y-axis 3. About both 4. Exit
--- Content provided by FirstRanker.com ---
Enter the choice: 1
Enter the shearing factor for x: 50
Fig.No 5.3 Shearing about x-axis
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 2
--- Content provided by FirstRanker.com ---
Enter the shearing factor for y: 50
Fig.No 5.4 Shearing about y-axis
1. About x-axis 2. About y-axis 3. About both 4. Exit
Enter the choice: 3
Enter the shearing factor for x: 50
--- Content provided by FirstRanker.com ---
Enter the shearing factor for y: 50
Enter the choice: 4
Fig.No 5.5 Shearing with both axis
Result:
Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.
--- Content provided by FirstRanker.com ---
Outcome:
Thus the outcome of implementing 2D geometric transformation has been met.
Application:
- Typography
- Cartography
- Technical drawing.
--- Content provided by FirstRanker.com ---
Viva-voce
- What is meant by reflection?
- Define – Shearing
- What are the applications for reflection?
- Compare reflection from mirroring.
- List out the advantages of using reflection.
--- Content provided by FirstRanker.com ---
Expt. No. 6
- WINDOW – TO – VIEWPORT TRANSFORMATION
Aim:
--- Content provided by FirstRanker.com ---
To write a C program to perform window-to-viewport transformation
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
--- Content provided by FirstRanker.com ---
Algorithm:
- Start the program.
- Input the minimum and maximum coordinates of a window,
- Input the minimum and maximum coordinates of a viewport,
- Input the coordinates of image to be displayed,
- Perform the scaling to transform the image to window and to viewport,
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output:
enter window port coordinates:
(xwmin,ywmin, xwmax, ywmax): 20 20 200 200
--- Content provided by FirstRanker.com ---
enter view port coordinates:
(xumin,yomin, xvmax,yumax): 20 20 400 400
enter vertices for triangle:
enter(x0,y0):50 50
enter(x1,y1): 150 150
--- Content provided by FirstRanker.com ---
enter(x2,y2):50 150
view port
Fig.No 6 Window to viewport transformation
Result:
Thus the program for performing window-to-viewport transformation is successfully executed in C.
--- Content provided by FirstRanker.com ---
Outcome:
Thus the outcome of implementing 2D geometric transformation has been met.
Application:
- To draw maps, sketch of areas and buildings
- Visualization
--- Content provided by FirstRanker.com ---
VIVA - VOCE
- Distinguish between window port and view port.
- What is the need of homogeneous coordinates?
- List out three font editing tools.
- Distinguish between window port and view port.
- Define - Clipping
- What is the need for homogeneous coordinates?
- List out two output primitives function.
- What is a decision parameter?
- List out the two software standards.
- Define - Bitmap
- Define - Pixelmap
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 7
COMPOSITE 2D TRANSFORMATIONS
Aim:
--- Content provided by FirstRanker.com ---
To write a program to perform the composite 2D transformations like successive translation, rotation and scaling using transformation equation in C
Software requirements:
C, C++ compilers, Java, OpenGL
Hardware requirements:
Dual core processor, DDR2 1GB RAM, 250 GB HDD
--- Content provided by FirstRanker.com ---
Algorithm:
- Start the program.
- Obtain the coordinates of the line xa, ya, xb, yb,
- Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,
- Find the translated coordinates by applying the formula as below.
- Get the rotation coordinates by applying the formula as
- Scaling is applied as
- Draw the transformed line with the new
This download link is referred from the post: Anna University B.Tech Lab Manual
--- Content provided by FirstRanker.com ---
x'= x + (tx1 + tx2) & y' = y + (ty1 + ty2)
It possesses associative property and successive translations are proved as additive.
x' = abs(xa - xb) cos(a1 + a2) - abs(ya - yb) sin(a1 + a2)
y' = abs(xa- xb) sin(a1 + a2) + abs(ya - yb) cos(a1 + a2)
--- Content provided by FirstRanker.com ---
It possesses associative property and successive rotations are also proved as additive.
x' = x* (sx1 * sx2)
y' = y * (sy1 * sy2)
It possesses associative property and successive scaling is multiplicative.
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---