Download Anna University B.Tech (Bachelor of Technology) CSE (Computer Science And Engineering) 5th Sem CS6513 Computer Graphics CG Lab Manual Question Paper.

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

35 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

7. Stop the program.

Sample Output:

Enter the translation factor: 50 50

Before Translation

After Translation

Fig.No 9 3D-Translation

Result:

Thus the program to perform translation, rotation and scaling on 3D objects were written and executed

successfully in C.

Outcome:

Thus the outcome of implementing 3D transformations has been met.

Application:

? To create motions in images

? Video games

? Image processing

? Presentation graphics

? Visualization

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

35 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

7. Stop the program.

Sample Output:

Enter the translation factor: 50 50

Before Translation

After Translation

Fig.No 9 3D-Translation

Result:

Thus the program to perform translation, rotation and scaling on 3D objects were written and executed

successfully in C.

Outcome:

Thus the outcome of implementing 3D transformations has been met.

Application:

? To create motions in images

? Video games

? Image processing

? Presentation graphics

? Visualization

36 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the steps involved in 3D transformation?

2. What do you mean by view plane?

3. What you mean by parallel projection?

4. What is the various representation schemes used in three dimensional objects?

5. What are the steps involved in 3D transformation pipeline?

6. What is view reference point?

7. What is vector dot product?

8. Write the parametric form for the line passing through the points (0,0,0) and (1,2,3)

9. Give an equation for the following planes (0,0,0) and normal to vector [0,1,0].

10. What is meant by perspective projection?

11. Define ? Depth Cueing

12. What are the 3D display methods?

13. What are the techniques to achieve realism in computer graphics?

14. Define ? Geometric Table

15. Define ? Attribute Table

16. What is meant by curved lines?

17. What is meant by quadric surfaces?

18. Write short notes on polygon surface.

19. Write short notes on polygon tables.

20. Define ? Curves

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

35 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

7. Stop the program.

Sample Output:

Enter the translation factor: 50 50

Before Translation

After Translation

Fig.No 9 3D-Translation

Result:

Thus the program to perform translation, rotation and scaling on 3D objects were written and executed

successfully in C.

Outcome:

Thus the outcome of implementing 3D transformations has been met.

Application:

? To create motions in images

? Video games

? Image processing

? Presentation graphics

? Visualization

36 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the steps involved in 3D transformation?

2. What do you mean by view plane?

3. What you mean by parallel projection?

4. What is the various representation schemes used in three dimensional objects?

5. What are the steps involved in 3D transformation pipeline?

6. What is view reference point?

7. What is vector dot product?

8. Write the parametric form for the line passing through the points (0,0,0) and (1,2,3)

9. Give an equation for the following planes (0,0,0) and normal to vector [0,1,0].

10. What is meant by perspective projection?

11. Define ? Depth Cueing

12. What are the 3D display methods?

13. What are the techniques to achieve realism in computer graphics?

14. Define ? Geometric Table

15. Define ? Attribute Table

16. What is meant by curved lines?

17. What is meant by quadric surfaces?

18. Write short notes on polygon surface.

19. Write short notes on polygon tables.

20. Define ? Curves

Viva-voce

37 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.10

IMPLEMENTATION OF 3D IMAGE PROJECTIONS

Aim:

To implement a C program for projection on 3D image

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Draw any image in the three dimensional plane,

3. Get the choice of axis as input from the user,

4. Perform the projection about the desired axis,

5. Display the projected image,

6. Stop the program.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

35 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

7. Stop the program.

Sample Output:

Enter the translation factor: 50 50

Before Translation

After Translation

Fig.No 9 3D-Translation

Result:

Thus the program to perform translation, rotation and scaling on 3D objects were written and executed

successfully in C.

Outcome:

Thus the outcome of implementing 3D transformations has been met.

Application:

? To create motions in images

? Video games

? Image processing

? Presentation graphics

? Visualization

36 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the steps involved in 3D transformation?

2. What do you mean by view plane?

3. What you mean by parallel projection?

4. What is the various representation schemes used in three dimensional objects?

5. What are the steps involved in 3D transformation pipeline?

6. What is view reference point?

7. What is vector dot product?

8. Write the parametric form for the line passing through the points (0,0,0) and (1,2,3)

9. Give an equation for the following planes (0,0,0) and normal to vector [0,1,0].

10. What is meant by perspective projection?

11. Define ? Depth Cueing

12. What are the 3D display methods?

13. What are the techniques to achieve realism in computer graphics?

14. Define ? Geometric Table

15. Define ? Attribute Table

16. What is meant by curved lines?

17. What is meant by quadric surfaces?

18. Write short notes on polygon surface.

19. Write short notes on polygon tables.

20. Define ? Curves

Viva-voce

37 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.10

IMPLEMENTATION OF 3D IMAGE PROJECTIONS

Aim:

To implement a C program for projection on 3D image

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Draw any image in the three dimensional plane,

3. Get the choice of axis as input from the user,

4. Perform the projection about the desired axis,

5. Display the projected image,

6. Stop the program.

38 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Projection about X-axis :

Enter the value of P : 45

Projection about Z-axis :

Enter the value of R : 45

Fig.No 10 3D-Projections

Result:

Thus the projections on the three dimensional images was performed successfully and the output was

verified.

Outcome:

Thus the outcome of implementing 3D image projection has been met.

Application:

? Simulation tools for Soft body dynamics including mesh collision detection

? Real time control during physics simulation and rendering

? Internal render engine with scanline ray tracing etc.

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.

28 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 1

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the translation factor in x-axis: 25 25

Enter the translation factor in y-axis: 0 0

Fig.No 7.0 Successive Translation

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 2

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the scaling factor in x-axis: 0.5 0.5

Enter the scaling factor in y-axis: 1 1

29 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 7.1 Successive Scaling

1.Successive Translation 2. Successive Scaling 3. Successive Rotation 4.Exit

Enter the choice: 3

Enter the x1 value: 100

Enter the y1 value: 100

Enter the x2 value: 200

Enter the y2 value: 200

Enter the rotation angle: 20 25

Fig.No 7.2 Successive Rotat

Result:

Thus the program for performing composite 2D transformations using transformation equation is successfully

executed in C.

Outcome:

Thus the outcome of implementing composite 2D transformation has been met.

Application:

? oracle documentation

? printers

? pixel based display

? monitors

30 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is transformation?

2. What is translation?

3. What is rotation?

4. What is scaling?

5. What is shearing?

6. What is reflection?

7. What are the different types of line type attributes?

8. What is pixel mask?

9. What is the area-fill attribute?

10. What is meant by homogeneous coordinates?

11. Define ? Geometric Transformation

12. What is meant by translation vector?

13. Define ? Scaling Factors

14. Define ? Composite Transformation

15. List some examples for rigid-body transformation matrix.

16. Write down the syntax to translate transformation matrices.

17. What are the raster functions in graphics packages?

18. What are the results of performing two successive block transfers into the same area of a frame buffer using

the binary arithmetic operations?

19. Write the routine to implement scaling as a raster transformation of a pixel block.

20. What is meant by frame buffer?

Viva-voce

31 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 8

LINE CLIPPING USING COHEN ? SUTHERLAND ALGORITHM

Aim:

To write a program in C to clip a line using Cohen-Sutherland line clipping algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Obtain the coordinates of the clipping window xmin, ymin, xmax, ymax,

3. Get the coordinates of the line to be clipped xa, ya, xb, yb,

4. Region codes are assigned to the line end points according to relative position with respect to the clipping

rectangle.

5. The two region codes of the line end points which passes through the clipping rectangle.

6. If the result is one (1 1 1 1), then the line is entirely outside the clipping window,

7. If the result is zero (0 0 0 0), then the line is completely inside the window hence we can save it for display,

8. For the intermediate results we have to find intersection point using line equation. The slope of the line is

given by the equation m = (yb - ya) / (xb - xa),

9. The point at which the line intersects the clipping window can be obtained using the equation x? <= x 1 + m(y

- y 1) & y? <= y 1 + m(x - x 1), where x is set either xmin or xmax and y is either ymin or ymax,

10. Using the intersection point the part of the outside the clipping window are clipped off,

11. Stop the program.

32 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the coordinates for rectangle: 200 200 300 300

Enter the coordinates for line:150 200 350 450

*

*

*

Fig.No 8 Line clip using Cohen-Sutherland algorithm

Result:

Thus the program to clip a line using Cohen-Sutherland algorithm has written and successfully executed in C.

Outcome:

Thus the outcome of implementing Cohen Sutherland line clipping algorithm has been met.

Application:

? Separation of synchronizing signals from composite picture signals

? Clip excessive noise spikes in FM transmitters

? Extracting part of a defined scene for viewing.

? Drawing and painting operations

33 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Clipping

2. Distinguish between window port and view port.

3. What is covering (exterior clipping)?

4. List out the various Text clipping.

5. What are the various representation schemes used in three dimensional objects?

6. Define ? Clip window

7. What are primitive types for clipping?

8. What is meant by point clipping?

9. What is meant by line clipping?

10. Differentiate Liang-Barsky Line clipping from Cohen Sutherland line clipping.

11. What is meant by vector method?

12. Define ? Polygon Clipping

13. Write down the function for displaying a filled polygon.

14. What do you mean by view plane?

15. What are applications for clipping?

16. What is meant by exterior clipping?

17. Define ? Curve Clipping

18. Write down the syntax for set view index?

19. What is meant by workstation transformation?

20. What is meant by view up vector?

Viva-voce

34 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.9

3D TRANSFORMATION ? TRANSLATION, ROATATION, SCALING

Aim:

To write a C program to perform translation, rotation and scaling on 3D objects

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Store the coordinate values in a homogeneous matrix,

3. Draw a 3D object with a specified coordinate value stored in a homogeneous matrix,

4. Perform translation with the use of translation matrix given below

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

where tx, ty, tz are the translation factors,

5. Perform rotation with the rotation matrix given by

1 0 0 0

0 cost -sint 0

0 sint cost 0

0 0 0 0

6. Perform scaling with the scaling matrix given by

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

where sx, sy, sz are scaling factors,

35 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

7. Stop the program.

Sample Output:

Enter the translation factor: 50 50

Before Translation

After Translation

Fig.No 9 3D-Translation

Result:

Thus the program to perform translation, rotation and scaling on 3D objects were written and executed

successfully in C.

Outcome:

Thus the outcome of implementing 3D transformations has been met.

Application:

? To create motions in images

? Video games

? Image processing

? Presentation graphics

? Visualization

36 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the steps involved in 3D transformation?

2. What do you mean by view plane?

3. What you mean by parallel projection?

4. What is the various representation schemes used in three dimensional objects?

5. What are the steps involved in 3D transformation pipeline?

6. What is view reference point?

7. What is vector dot product?

8. Write the parametric form for the line passing through the points (0,0,0) and (1,2,3)

9. Give an equation for the following planes (0,0,0) and normal to vector [0,1,0].

10. What is meant by perspective projection?

11. Define ? Depth Cueing

12. What are the 3D display methods?

13. What are the techniques to achieve realism in computer graphics?

14. Define ? Geometric Table

15. Define ? Attribute Table

16. What is meant by curved lines?

17. What is meant by quadric surfaces?

18. Write short notes on polygon surface.

19. Write short notes on polygon tables.

20. Define ? Curves

Viva-voce

37 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No.10

IMPLEMENTATION OF 3D IMAGE PROJECTIONS

Aim:

To implement a C program for projection on 3D image

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Draw any image in the three dimensional plane,

3. Get the choice of axis as input from the user,

4. Perform the projection about the desired axis,

5. Display the projected image,

6. Stop the program.

38 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Projection about X-axis :

Enter the value of P : 45

Projection about Z-axis :

Enter the value of R : 45

Fig.No 10 3D-Projections

Result:

Thus the projections on the three dimensional images was performed successfully and the output was

verified.

Outcome:

Thus the outcome of implementing 3D image projection has been met.

Application:

? Simulation tools for Soft body dynamics including mesh collision detection

? Real time control during physics simulation and rendering

? Internal render engine with scanline ray tracing etc.

39 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Define ? Projection

2. What is meant by perspective projection?

3. What is vanishing point?

4. State the basic types of projections.

5. What is boundary representation?

6. What is space-partitioning representation?

7. What is meant by parallel projection?

8. What is blobby object?

9. What is meant by polygon mesh?

10. What is Spline?

11. Define ? Spline Curves

12. List any two properties of Bezier curve.

13. List any two properties of B-spline curve.

14. List any advantages of B-spline curve

15. Make a comparison of beizer and b-spline algorithms for curve generation

16. What is meant by Uniform periodic B-Spline curves.

17. What is blobby object?

18. What is meant by polygon mesh?

19. What is space ?partitioning representation?

20. Why cubic Bezier curves are chosen?

Viva-voce

FirstRanker.com - FirstRanker's Choice

?

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

CS6513 ? COMPUTER GRAPHICS LABORATORY

V SEMESTER - R 2013

Name : ______________________________________

Register No. : ______________________________________

Section : ______________________________________

LABORATORY MANUAL

1 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

College of Engineering is committed to provide highly disciplined, conscientious and

enterprising professionals conforming to global standards through value based quality education and training.

? 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

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

To strive for acquiring, applying and imparting knowledge in Computer Science and Engineering through

quality education and to provide enthusiastic professionals with commitment

? 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

VISION

VISION

MISSION

MISSION

2 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

1. Fundamentals

To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering

that will would them to be successful professionals

2. 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

3. 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

4. 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

5. 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

3 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

PROGRAMME OUTCOMES (POs)

a) To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and

Engineering field

b) To design and conduct experiments as well as to analyze and interpret and apply the same in the career

c) To design and develop innovative and creative software applications

d) To understand a complex real world problems and develop an efficient practical solutions

e) To create, select and apply appropriate technique, resources, modern engineering and IT tools

f) To understand their roles as professionals and give the best to the soicety

g) To develop a system that will meet expected need with realistic constraints such as economical,

environmental, social, political, ethical, safe and sustainable

h) To communicate effectively and make others understand exactly what they are trying to convey in both verbal

and written forms

i) To engage lifelong learning and exhibit their technical skills

j) To develop and manage projects in multidisciplinary environments

4 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

SYLLABUS

? 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

LIST OF EXPERIMENTS:

1. Implementation of algorithms for drawing 2D primitives ? Line (DDA, Bresenham?s) ? all slopes circle (midpoint).

2. 2D geometric transformations ? translation, rotation, scaling, reflection, shear, window to viewport.

3. Composite 2D transformations.

4. Line clipping.

5. 3D transformations - translation, rotation, scaling.

6. 3D projections ? parallel, perspective.

7. Creating 3D scenes.

8. Image editing and manipulation - basic operations on image using any image editing software.

9. Creating gif animated images, image optimization.

10. 2D Animation ? to create Interactive animation using any authoring tool

? Create 3D graphical scenes using open graphics library suits.

? Implement image manipulation and enhancement.

? Create 2D animations using tools.

COURSE OBJECTIVES

COURSE OUTCOMES

5 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

CS6513 ? COMPUTER GRAPHICS LABORATORY

CONTENTS

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

6 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, and yb,

3. Find the x-coordinate difference and y-coordinate difference

dx = xb - xa & dy = yb ? ya,

4. Compare the difference and decide the step value

if (dx > dy) step = dx

else

step = dy,

5. Find the increment values of coordinates

xi = dx / step

yi = dy / step,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels using the formula xa = xa + xi & ya = ya + yi,

8. Repeat the steps till reaching the endpoints i.e., ya = yb & xa = xb,

9. Stop the program.

7 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the starting coordinates: 100 100

Enter the ending coordinates: 200 200

Fig.No 1 Line using DDA

Result:

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

8 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the advantages of DDA algorithm?

2. Define ? Computer Graphics

3. What are the properties of video display devices?

4. What are the various applications of computer graphics?

5. What is resolution?

6. What is a bitmap?

7. List out the important characteristics of video display device.

8. What is meant by pixel?

9. What is intensity?

10. Define ? DDA Algorithm

Viva-voce

9 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 2

LINE DRAWING USING BRESENHAM?S ALGORITHM

Aim:

To write a program in C to draw a line using Bresenham?s algorithm

Software requirements:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. Read the starting and ending coordinates xa, ya, xb, yb,

3. Find the x-coordinate difference and y-difference

dx = xb - xa & dy = yb ? ya,

4. Calculate decision parameter ?p? value

p = 2dy-dx,

5. Fix the starting and ending coordinates

if(xa < xb)

xstart = xa ystart = ya xend = xb

yend = yb

else

xstart = xb

ystart = yb

xend = xa

yend = ya,

6. Display the starting point using the function putpixel(xa,ya,4),

7. Find adjacent pixels and display it using the formula given below

x =xstart & y=ystart

while(x < xend)

x = x + 1

if(p < 0)

10 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

p = p + 2 * dy

else

p = p + 2 * (dy - dx)

y = y + 1

putpixel(x,y,1),

8. Repeat the step 7 till reaching the end points,

9. Stop the program.

Sample Output:

Enter the xa & ya value: 200 200

Enter the xb & yb value: 350 45

Fig.No 2 Line using Bresenham?s

Result:

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

11 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is the property that reduces the pixel calculation in Bresenham?s circle drawing

algorithm?

2. What is the equation used to find decision parameter in Bresenham?s line drawing algorithm?

3. What is meant by rasterization?

4. List out the advantages and disadvantages of DVST.

6. What are the two techniques for producing color displays with a CRT?

7. What is vertical retrace of the electron beam?

8. What is meant by frame buffer?

9. Distinguish between track ball and space ball.

10. Define ? Digitizers

Viva-voce

12 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 3

CIRCLE DRAWING USING BRESENHAM?S CIRCLE ALGORITHM

Aim:

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

Algorithm:

1. Start the program.

2. Get the radius and center of the circle r, xc, yc,

3. Obtain the first point on the circumference of a circle centered on the origin as (X 0, Y 0) = (0, r),

4. Calculate the initial value of the decision parameter as p = 5/4 ? r,

5. At each x k position, starting at k=0, perform the following test if(p k < 0),

the next point along the circle centered on (0,0) is (x k+1, y k+1) and p k+1 = p k + 2x k+1 + 1

Otherwise the next point along the circle is (x k+1, y k-1) and

p k+1 = p k + 2x k+1 + 1 - 2y k+1 ,where 2x k+1 = 2x k+2 and 2y k+1 = 2y k ? 2.

6. Determine symmetry points in other seven octants,

7. 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,

8. Repeat the steps 5 to 7 until x >= y,

9. Stop the program.

13 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Enter the xa value: 200

Enter the ya value: 200

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:

Thus the outcome of implementing 2D primitives has been attained.

Application:

? Image processing

? Computer art

? Presentation graphics

14 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the two basic techniques for producing color display with a CRT?

2. Give three difference between shadows mask and beam penetration method.

3. Differentiate LCD from LED.

4. Differentiate plasma panel display from thin film electroluminescent display.

5. Define ? Bresenham?s Circle Algorithm

Viva-voce

15 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 4

2D GEOMETRIC TRANSFORMATIONS

BASIC 2D TRANSFORMATIONS ? TRANSLATION, ROTATION, SCALING

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx, ty, rotation angle a & scaling factors sx, sy,

4. Find the translated coordinates by applying the angle as

x

?

= x + tx & y

?

= y + ty.

5. Get the rotation coordinates by applying the angle as

x

?

= abs(xa - xb) cosa - abs(ya - yb) sina

y

?

= abs(xa - xb) sina + abs(ya - yb) cosa,

6. Scaling is applied as

x

'

= x * sx

y

?

= y * sy,

7. Draw the transformed line with the new coordinates (x?, y?),

8. Similarly obtain the coordinates of rectangle / triangle as consecutive set of line end points and apply all the

basic transformations,

9. Stop the program.

16 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

Line

1. Translation 2. Scaling 3. Rotation 4. Exit

Enter the choice: 1

Enter the x1 value: 100

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

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

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

17 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Used in traditional printing

? Drawing technologies

18 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What are the changes accomplished by adding attributes?

2. Which transformation produces a mirror image of an object?

3. Which is not a basic transformation operation?

4. What is transformation?

5. What is a view plane?

6. What are the steps involved in 3D transformation pipeline?

7. What is fixed point scaling?

8. Distinguish between uniform scaling and differential scaling.

9. What are the different kinds of co-ordinate representation?

Viva-voce

19 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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:

C, C++ compilers, Java, OpenGL

Hardware requirements:

Dual core processor, DDR2 1GB RAM, 250 GB HDD

Algorithm:

1. Start the program.

2. For reflection obtain the coordinates of the triangle xa, ya, xb, yb, xc, yc,

3. Calculate the reflection as, x` = x + 2 * (320 - x) and y` = y + 2 * (240 - y),

4. For shearing obtain the coordinates of the square xa, ya, xb, yb, xc, yc, xd, yd,

5. Shearing points can be calculated as x` = x + shx & y` = y + shy, where shx, shy are the shearing factors,

6. Draw the transformed objects with the new coordinates (x`, y`),

7. Stop the program.

20 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Sample Output:

1. Reflection 2. Shearing 3. Exit

Enter the choice: 1

Enter the xa&ya value: 200 100

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

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

Fig.No 5.2 Reflection on both

21 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

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

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

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

Enter the shearing factor for y: 50

Fig.No 5.4 Shearing about y-axis

22 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. About x-axis 2. About y-axis 3. About both 4. Exit

Enter the choice: 3

Enter the shearing factor for x: 50

Enter the shearing factor for y: 50

Fig.No 5.5 Shearing with both axis

Enter the choice: 4

Result:

Thus the program for performing 2D transformations reflection and shearing is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? Typography

? Cartography

? Technical drawing.

23 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. What is meant by reflection?

2. Define ? Shearing

3.What are the applications for reflection?

4.Compare reflection from mirroring.

5.List out the advantages of using reflection.

Viva-voce

24 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 6

WINDOW ? TO ? VIEWPORT TRANSFORMATION

Aim:

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

Algorithm:

1. Start the program.

2. Input the minimum and maximum coordinates of a window,

3. Input the minimum and maximum coordinates of a viewport,

4. Input the coordinates of image to be displayed,

5. Perform the scaling to transform the image to window and to viewport,

6. Stop the program.

Sample Output:

25 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Fig.No 6 Window to viewport transformation

Result:

Thus the program for performing window-to-viewport transformation is successfully executed in C.

Outcome:

Thus the outcome of implementing 2D geometric transformation has been met.

Application:

? To draw maps, sketch of areas and buildings

? Visualization

26 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

1. Distinguish between window port and view port.

2. What is the need of homogeneous coordinates?

3. List out three font editing tools.

4. Distinguish between window port and view port.

5. Define ? Clipping

6. What is the need for homogeneous coordinates?

7. List out two output primitives function.

8. What is a decision parameter?

9. List out the two software standards.

10. Define ? Bitmap

11. Define ? Pixelmap

VIVA - VOCE

27 Format No.:FirstRanker/Stud/LM/34/Issue:00/Revision:00

Expt. No. 7

COMPOSITE 2D TRANSFORMATIONS

Aim:

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

Algorithm:

1. Start the program.

2. Obtain the coordinates of the line xa, ya, xb, yb,

3. Get the translation factors tx1, ty1, tx2, ty2 rotation angles a1, a2 & scaling factors sx1, sy1, sx2, sy2,

4. Find the translated coordinates by applying the formula as below.

x

'

= x + (tx1 + tx2) & y?

= y + (ty1 + ty2).

It possesses associative property and successive translations are proved as additive.

5. Get the rotation coordinates by applying the formula as

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)

It possesses associative property and successive rotations are also proved as additive.

6. Scaling is applied as

x

'

= x * (sx1 * sx2)

y?

= y * (sy1 * sy2)

It possesses associative property and successive scaling is multiplicative.

7. Draw the transformed line with the new coordinates (x?, y?),

8. Stop the program.