0% found this document useful (0 votes)
19 views38 pages

CGM File Lab Mannul

The document outlines the vision, mission, program outcomes, education objectives, and specific outcomes for the Computer Graphics and Multimedia course at Swami Vivekananda College of Engineering for the Jan-June 2024 semester. It details the expected competencies of graduates, including engineering knowledge, problem analysis, design solutions, and ethical responsibilities. Additionally, it includes practical assignments and C++ program implementations for various graphics algorithms.

Uploaded by

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

CGM File Lab Mannul

The document outlines the vision, mission, program outcomes, education objectives, and specific outcomes for the Computer Graphics and Multimedia course at Swami Vivekananda College of Engineering for the Jan-June 2024 semester. It details the expected competencies of graduates, including engineering knowledge, problem analysis, design solutions, and ethical responsibilities. Additionally, it includes practical assignments and C++ program implementations for various graphics algorithms.

Uploaded by

Karim Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 38

SWAMI VIVEKANDA COLLEGE OF ENGINEERING,

INDORE
Department of Information Technology

Session: Jan-June 2024


Semester- VI

Subject Name & Code:-


Computer Graphics and Multimedia & IT 601

Submitted To: - Submitted By:-


Mrs. Neha Khandalwal Name: Karim Ahmed
Enrollment No:
0822IT211022

1
VISION OF THE DEPARTMENT

To achieve global standard in quality of education, research & development in Information


Technology by adapting to the rapid technological advancement to empowering the IT
industry with the wings of knowledge and power of innovation though knowledge creation,
acquisition and dissemination for the benefit of Society and Humanity.

MISSION OF THE DEPARTMENT

M1: To provide students with Innovative and research skills, which is need of the hour
for technical students.
M2: To impart knowledge to the students of Information Technology with relevant core and
practical knowledge inculcating real time experience in the promising field of computing.
M3: To prepare the graduates to meet information technology challenges with a blend of
social, human, ethical and value based education.
M4: To engage in emerging research areas and establishing leadership.
M5: To contribute to the community services at large as well as catering to socio-economic
goals in local and national levels.

2
PROGRAM OUTCOMES (POs)

PO1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.

PO2. Problem analysis: Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.

PO3.Design/development of solutions: Design solutions for complex engineering problems


and design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.

PO4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.

PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.

PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.

PO7. Environment and sustainability: Understand the impact of the professional


engineering solutions in societal and environmental contexts, and demonstrate the knowledge
of, and need for sustainable development.

PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.

PO9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.

3
PO10. Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.

PO11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.

PROGRAM EDUCATION OBJECTIVES (PEOs)

PEO-I: Meet Market Demands: To prepare students to become a successful engineer to


meet the demand driven needs of industries/technical profession.

PEO-II: Core Competence: Graduates will demonstrate core competence in mathematical


Scientific and basic engineering fundamentals necessary to formulate, analyze and
solve engineering problems and also to pursue advanced study or research.

PEO-III: Design and Analysis : Graduates will demonstrate good breadth of knowledge in
core areas of Information Technology and related engineering so as to comprehend
engineering trade-offs, analyze, design, and synthesize data and technical concepts to create
novel designs in solving the real life problems.

PEO-IV: Professional Responsibility : Graduates will demonstrate professional


responsibility by offering a wide spectrum of consultancy and testing services by addressing
social, cultural, economic, sustainability, and environmental considerations in the solution of
real world engineering problems.

4
PEO-V: Life-long learning: Graduates will engage themselves in life-long learning
through independent study and by participating in professional activities or continuing
education

PROGRAM SPECIFIC OUTCOMES (PSOs)

PSO1: Understand, Analyze and develop computer programs for efficient analysis and
design of computer based system.
PSO2: Apply standard practices and strategies in software development.

PSO3: Employ modern computer language software tools and platforms in creating
innovative career paths to be a successful professional

Course Outcomes

Upon completion of this course, students will be able to

1. Understand the core concepts of computer graphics.

2. Implement various shapes drawing algorithms.

3. Apply geometric transformations on graphic objects and also implement clipping, shading
and color models.

4. Understand multimedia systems architecture, multimedia components and use various


multimedia tools.

5. Perform activities involved in design, development and testing of modeling, rendering,


shading and animation.

5
Swami Vivekananda College of Engineering

INDEX

Student Practical Evaluation Sheet

Sr. Lab Assignments Date Page Signatur


No. No. e
1. C++ program implementing DDA 2
line algorithm.

2. C++ program implementing 5


Bresenham’s line algorithm.

3. C++ program implementing 8


Midpoint Circle Algorithm.

4. C++ program implementing 11


Bresenham’s Circle Algorithm.

5. C++ program implementing 13


Bezier curve algorithm.

6. C++ program implementing 2D & 17


3D Translation.

7. C++ program implementing 2D & 22


3D Scaling.

8. C++ program implementing 2D & 28


3D Rotation.

9. C++ program implementing shear 33


transformation.

10. C++ program implementing 37


reflection about x-axis, y-axis and
origin.

Program No.-1

6
Problem Definition:
Write a c++ program to implement DDA Line Algorithm.

Implementation:
#include <iostream.h>

#include <conio.h>

#include <math.h>

#include <graphics.h>

void main()

float x, y, x1, y1, x2, y2, dx, dy, xinc, yinc, step;

int i, gd=DETECT, gm;

initgraph(&gd, &gm, "c:\\TC\\BGI");

cout<<"\nEnter value of x1 and y1 : ";

cin>>x1>>y1;

cout<<"\nEnter value ofx2 and y2 : ";

cin>>x2>>y2;

dx=abs(x2-x1);

dy=abs(y2-y1);

if(dx>=dy)

step=dx;

else

step=dy;

7
xinc=dx/step;

yinc=dy/step;

x=x1;

y=y1;

for(i=1;i<=step;i++)

putpixel(x,y,WHITE);

x=x+xinc;

y=y+yinc;

getch();

8
Output:

Program No.-2

Problem Definition:
Write a c++ program to implement Bresenham’s Line Algorithm.

Implementation:
#include <iostream.h>

#include <conio.h>

#include <graphics.h>

void main()

9
int x1, x2, y1, y2;

int i=0, gd=DETECT, gm, p, dx, dy;

detectgraph(&gd, &gm);

initgraph(&gd, &gm, "c:\\TC\\BGI");

cout<<"\nEnter value of x1 and x2 : ";

cin>>x1>>x2;

cout<<"\nEnter value of y1 and y2 : ";

cin>>y1>>y2;

dx=x2-x1;

dy=y2-y1;

p=(2*dy)-dx;

while(i<dx)

if(p<0)

putpixel(x1++, y1, WHITE);

p=p+(2*dy);

else

putpixel(x1++, y1++, WHITE);

p=p+(2*dy)-(2*dx);

i++;

10
}

getch();

closegraph();

Output:

11
Program No.-3

Problem Definition:
Write a c++ program to implement Midpoint Circle Algorithm.

Implementation:
#include <iostream.h>

#include <conio.h>

#include <graphics.h>

void main()

int gd=DETECT, gm, x, y, xc, yc, r,p;

initgraph(&gd,&gm, "C:\\TC\\BGI");

cout<<"\nEnter radius of the circle : ";

cin>>r;

cout<<"\nEnter center of the circle : ";

cin>>xc>>yc;

p=1-r;

x=0;

y=r;

while(x<=y)

putpixel(xc+x,yc+y,5);

putpixel(xc+y,yc+x,5);

putpixel(xc+y,yc-x,5);

12
putpixel(xc+x,yc-y,5);

putpixel(xc-x,yc-y,5);

putpixel(xc-y,yc-x,5);

putpixel(xc-y,yc+x,5);

putpixel(xc-x,yc+y,5);

if(p>=0)

x=x+1;

y=y-1;

p=p+2*x-2*y+1;

else

x=x+1;

y=y;

p=p+2*x+1;

getch();

closegraph();

Output:

13
Program No.-4

Problem Definition:
Write a c++ program to implement Bresenham’s Circle Algorithm.

Implementation:
#include <iostream.h>

#include <conio.h>

#include <graphics.h>

void main()

int x, y, xc, yc, gd=DETECT, gm, p, r,i;

initgraph(&gd, &gm, "C:\\TC\\BGI");

14
cout<<"\nEnter radius of circle : ";

cin>>r;

cout<<"\nEnter center coordinates of circle :";

cin>>xc>>yc;

p=3-2*r;

x=0;

y=r;

while(x<=y)

putpixel(xc+x,yc+y,5);

putpixel(xc+y,yc+x,5);

putpixel(xc+y,yc-x,5);

putpixel(xc+x,yc-y,5);

putpixel(xc-x,yc-y,5);

putpixel(xc-y,yc-x,5);

putpixel(xc-y,yc+x,5);

putpixel(xc-x,yc+y,5);

if(p>=0)

x+=1;

y-=1;

p=p+4*x-4*y+10;

15
else

x+=1;

p=p+4*x+6;

getch();

closegraph();

Output:

Program No.-5
16
Problem Definition:
Write a c++ program to implement Bezier Curve Algorithm.

Implementation:
#include<iostream.h>

#include<conio.h>

#include<graphics.h>

#include<dos.h>

void main()

int gd=DETECT, gm;

initgraph(&gd,&gm,"C:\\TC\\BGI");

int x[4], y[4], px, py, i;

cout<<"\nEnter four control points of bezier curve :\n";

for(i=0;i<4;i++) cin>>x[i]>>y[i];

double t;

for(t=0.0;t<=1.0;t+=0.001)

px=(1-t)*(1-t)*(1-t)*x[0]+3*t*(1-t)*(1-t)*x[1]+3*t*t*(1-t)*x[2]+t*t*t*x[3];

py=(1-t)*(1-t)*(1-t)*y[0]+3*t*(1-t)*(1-t)*y[1]+3*t*t*(1-t)*y[2]+t*t*t*y[3];

putpixel(px,py,GREEN);

delay(2);

getch();

17
closegraph();

Output:

Program No.-6

Problem Definition:
Write a c++ program to implement 2D and 3D Translation.

Implementation:
#include<iostream.h>

#include<conio.h>

#include<graphics.h>

18
int maxx,maxy,midx,midy;

void axis()

getch();

cleardevice();

line(midx,0,midx,maxy);

line(0,midy,maxx,midy);

// function to translate rectangle

void translateRectangle ( int P[][2], int T[])

/* init graph and rectangle() are used for

representing rectangle through graphical functions */

int gd = DETECT, gm, errorcode;

initgraph (&gd, &gm, "C:\\TC\\BGI");

setcolor (2);

// rectangle (Xmin, Ymin, Xmax, Ymax)

// original rectangle

rectangle (P[0][0], P[0][1], P[1][0], P[1][1]);

// calculating translated coordinates

P[0][0] = P[0][0] + T[0];

P[0][1] = P[0][1] + T[1];

P[1][0] = P[1][0] + T[0];

P[1][1] = P[1][1] + T[1];

// translated rectangle (Xmin, Ymin, Xmax, Ymax)

19
// setcolor(3);

rectangle (P[0][0], P[0][1], P[1][0], P[1][1]);

// closegraph();

// driver program

int main()

int ch;

cout<<"\n1. 2D Translation";

cout<<"\n2. 3D Translation";

cout<<"\n3. Exit";

cout<<"\nEnter your choice: ";

cin>>ch;

switch(ch){

case 1:

// Xmin, Ymin, Xmax, Ymax as rectangle

// coordinates of top left and bottom right points

int P[2][2] = {200, 100, 250, 180};

int T[] = {20, 15}; // translation factor

translateRectangle (P, T);

break;

case 2:

int x,y,z,o,x1,x2,y1,y2;

int gd=DETECT,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"c:\\tc\\bgi");

20
maxx=getmaxx();

maxy=getmaxy();

midx=maxx/2;

midy=maxy/2;

axis();

bar3d(midx+50,midy-100,midx+100,midy-50,20,1);

cout<<"Enter translation factor: ";

cin>>x>>y;

cout<<"After translation: ";

bar3d(midx+x+50,midy-(y+100),midx+x+100,midy-
(y+50),20,1);

break;

case 3:

break;

cout<<"\nPress enter to continue...";

getch();

return 0;

21
Output:

Program No.-7

Problem Definition:
Write a c++ program to implement 2D and 3D Scaling.

Implementation:
#include<iostream.h>

#include<conio.h>

#include<math.h>

#include<graphics.h>

// Matrix Multiplication to find new Coordinates.

// s[][] is scaling matrix. p[][] is to store

// points that needs to be scaled.

// p[0][0] is x coordinate of point.

22
// p[1][0] is y coordinate of given point.

void findNewCoordinate(int s[][2], int p[][1])

int temp[2][1] = { 0 };

int i, j, k;

for (i = 0; i < 2; i++)

for (j = 0; j < 1; j++)

for (k = 0; k < 2; k++)

temp[i][j] += (s[i][k] * p[k][j]);

p[0][0] = temp[0][0];

p[1][0] = temp[1][0];

// Scaling the Polygon

void scale(int x[], int y[], int sx, int sy)

// Triangle before Scaling

line(x[0], y[0], x[1], y[1]);

line(x[1], y[1], x[2], y[2]);

line(x[2], y[2], x[0], y[0]);

// Initializing the Scaling Matrix.

int s[2][2] = { sx, 0, 0, sy };

int p[2][1];

// Scaling the triangle

for (int i = 0; i < 3; i++)

23
{

p[0][0] = x[i];

p[1][0] = y[i];

findNewCoordinate(s, p);

x[i] = p[0][0];

y[i] = p[1][0];

// Triangle after Scaling

line(x[0], y[0], x[1], y[1]);

line(x[1], y[1], x[2], y[2]);

line(x[2], y[2], x[0], y[0]);

int maxa,maxb,mida,midb;

void axis()

cout<<"\nPress enter to initialize...";

getch();

cleardevice();

line(mida,0,mida,maxb);

line(0,midb,maxa,midb);

// driver program

int main()

24
int ch;

cout<<"\n1. 2D Scaling";

cout<<"\n2. 3D Scaling";

cout<<"\n3. Exit";

cout<<"\nEnter your choice: ";

cin>>ch;

switch(ch){

case 1:

int x[] = { 100, 200, 300 };

int y[] = { 200, 100, 200 };

int sx = 2, sy = 2;

int gd, gm;

detectgraph(&gd, &gm);

initgraph(&gd, &gm,"C:\\TC\\BGI");

scale(x, y, sx,sy);

break;

case 2:

int a,b,c;

int graphd=DETECT,graphm;

detectgraph(&graphd,&graphm);

initgraph(&gd,&gm,"c:\\tc\\bgi");

maxa=getmaxx();

maxb=getmaxy();

mida=maxa/2;

midb=maxb/2;

25
axis();

bar3d(mida+50,midb-100,mida+100,midb-50,20,1);

cout<<"Enter scaling factors: ";

cin>>a>>b>>c;

cout<<"After scaling: ";

bar3d(mida+(a*50),midb-(b*100),mida+(a*100),midb-
(b*50),20*c,1);

break;

case 3:

break;

cout<<"\nPress enter to continue...";

getch();

return 0;

Output:

26
27
Program No.-8

Problem Definition:
Write a c++ program to implement 2D and 3D Rotation.

Implementation:
#include<iostream.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

int maxx,maxy,midx,midy;

void axis()

getch();

cleardevice();

line(midx,0,midx,maxy);

line(0,midy,maxx,midy);

// driver program

int main()

int ch;

cout<<"\n1. 2D Translation";

cout<<"\n2. 3D Translation";

28
cout<<"\n3. Exit";

cout<<"\nEnter your choice: ";

cin>>ch;

switch(ch){

case 1:

int gd=DETECT,gm,x1,x2,y1,y2,x4,y4;

initgraph(&gd,&gm,"C:\\Tc\\BGI");

float angle=0,ang;

cout<<"\nROTATION OF A LINE\n";

cout<<"Enter the first coordinate of a line:";

cin>>x1>>y1;

cout<<"Enter the second coordinate of a line:";

cin>>x2>>y2;

line(x1,y1,x2,y2);

cout<<"Enter the angle:";

cin>>ang;

angle=(ang*3.14)/180;

setcolor(RED);

x4=x2-(((x2-x1)*cos(angle))-((y2-y1)+sin(angle)));

y4=y2-(((x2-x1)*sin(angle))+((y2-y1)*cos(angle)));

line(x2,y2,x4,y4);

break;

case 2:

int x,y,z,o;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"c:\\tc\\bgi");

maxx=getmaxx();

29
maxy=getmaxy();

midx=maxx/2;

midy=maxy/2;

axis();

bar3d(midx+50,midy-100,midx+100,midy-50,20,1);

cout<<"Enter rotating angle";

cin>>o;

x1=50*cos(o*3.14/180)-100*sin(o*3.14/180);

y1=50*sin(o*3.14/180)+100*cos(o*3.14/180);

x2=100*cos(o*3.14/180)-50*sin(o*3.14/180);

y2=100*sin(o*3.14/180)+50*cos(o*3.14/180);

axis();

cout<<"After rotation about z axis";

bar3d(midx+x1,midy-y1,midx+x2,midy-y2,20,1);

axis();

cout<<"After rotation about x axis";

bar3d(midx+50,midy-x1,midx+100,midy-x2,20,1);

axis();

cout<<"After rotation about yaxis";

bar3d(midx+x1,midy-100,midx+x2,midy-50,20,1);

break;

case 3:

break;

cout<<"\nPress enter to continue...";

getch();

return 0;

30
}

Output:

31
Program No.-9

Problem Definition:
Write a c++ program to implement shear transformation.

Implementation:
#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

#include <iostream.h>

int x,y,az,w,ch2;

float x1,y1,az1,w1,x1s,y1s;

int main()

int gm ,gr;

clrscr();

detectgraph(&gm,&gr);

initgraph(&gm,&gr,"C:\\TC\\BGI");

printf("Enter the upper left corner of the rectangle:\n");

scanf("%d%d",&x,&y);

printf("Enter the lower right corner of the rectangle:\n");

scanf("%d%d",&az,&w);

rectangle(x,y,az,w);

printf("*******Shearing******\n\n");

32
printf("1.x-direction shear\n2.y-direction shear\nEnter your choice:\
n");

scanf("%d",&ch2);

switch(ch2)

case 1:

printf("Enter the value of shear:\n");

scanf("%f",&x1s);

x1=x+(y*x1s);

y1=y;

az1=az+(w*x1s);

w1=w;

rectangle(x1,y1,az1,w1);

break;

case 2:

printf("Enter the value of shear:\n");

scanf("%f",&y1s);

x1=x;

y1=y+(x*y1s);

az1=az;

w1=w+(az*y1s);

rectangle(x1,y1,az1,w1);

break;

getch();

closegraph();

33
return 0;

Output:

34
Program No.-10

Problem Definition:
Write a c++ program to implement reflection about x-axis, y-axis and origin.

Implementation:
#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int a,a1,b,b1,c,c1,xt,ch;

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

a=getmaxx();

a1=getmaxy();

b=a/2;

b1=a1/2;

line(b,0,b,a1);

35
line(0,b1,a,b1);

line(400,200,600,200);

line(400,200,400,100);

line(400,100,600,200);

printf("1.origin\n");

printf("2.x-axis\n");

printf("3.y-axis\n");

printf("4.exit\n");

do

printf("Enter your choice\n");

scanf("%d",&ch);

switch(ch)

case 1:

c=400-b;c1=200-b1;

line(b-c,b1-c1,b-c-200,b1-c1);

line(b-c,b1-c1,b-c,b1-c1+100);

line(b-c,b1-c1+100,b-c-200,b1-c1);

break;

case 2:

c=400-b;c1=200-b1;

line(b+c,b1-c1,b+c+200,b1-c1);

line(b+c,b1-c1,b+c,b1-c1+100);

line(b+c,b1-c1+100,b+c+200,b1-c1);

break;

36
case 3:

c=400-b;c1=200-b1;

line(b-c,b1+c1,b-c-200,b1+c1);

line(b-c,b1+c1,b-c,b1+c1-100);

line(b-c,b1+c1-100,b-c-200,b1+c1);

break;

}while(ch<4);

getch();

closegraph();

Output:

37
38

You might also like