Join Our Email Alerts-Subscribe
Important Note:Login & Check Your Email Inbox and Activate Confirmation Link



Enter Your Email :

Copyright Disclaimer:
Section 107 of the Copyright Act Fair Use Contents .
We are forwarding content link(s) from our website to content website & We are not serving any contents.
Main Source:Google.com.All the Content PDF link(s) is/are obtained from GoogleSearch
for the purpose of Education & Teaching Intention. Not for commercial purpose.
Technicalsymposium.com is not liable/responsible for any copyright issues.

Computer Graphics Source Codes & Study Notes-Free Download


Free Download of All Study Materials & ebooks PDF-Click & Download



Computer Graphics Lab Codings-2 DIMENSIONAL TRANSFORMATION

void menu();

void input();

void output();

void translation();

void rotation();

void scaling();

void shearing();

void reflection();

int a[10][2],i,x,option,temp,angle,tx,ty,fx,fy,sh,k,n,axis,y;

float sx,sy;

void menu()

{

printf("menu\n");

printf("1.Translation\n");

printf("2.rotation\n");

printf("3.scaling\n");

printf("4.shearing\n");

printf("5.reflection\n");

printf("6.exit\n");

printf("enter the choice:");

scanf("%d",&option);

switch(option)

{

case 1:

input();

translation();

break;

case 2:

input();

rotation();

break;

case 3:

input();

scaling();

break;

case 4 :

input();

shearing();

break;

case 5:

input();

reflection();

break;

case 6:

exit(0);

break;

}

}

void input()

{

printf("enter the number of vertices:" );

scanf("%d",&n);

for(i=0;i
{

printf("enter the coordinates:");

scanf("%d%d%d%d",&a[i][0],&a[i][1],&a[i+1][0],&a[i+1][1]);

}

}

void output()

{

cleardevice();

for(i=0;i
{

line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]);

}

}

void translation()

{

output();

printf("enter the tranformation vertex tx,ty:\n");

scanf("%d%d",&tx,&ty);

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

{

a[i][0]=a[i][0]+tx;

a[i][1]=a[i][1]+ty;

}

output();

delay(10);

menu();

}

void rotation()

{

output();

printf("enter the rotating angle:");

scanf("%d",&y);

printf("enter the pivot point:");

scanf("%d%d",&fx,&fy);

k=(y*3.14)/180;

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

{

a[i][0]=fx+(a[i][0]-fx)*cos(k)-(a[i][1]-fy)*sin(k);

a[i][1]=fy+(a[i][0]-fx)*sin(k)-(a[i][1]-fy)*cos(k);

}

output();

delay(10);

menu();

}

void scaling()

{



output();

printf("enter the scaling factor\n");

scanf("%f%f",&sx,&sy);

printf("enter the fixed point:");

scanf("%d%d",&fx,&fy);

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

{

a[i][0]=a[i][0]*sx+fy*(1-sx);

a[i][1]=a[i][1]*sy+fy*(1-sy);

}

output();

delay(10);

menu();

}

void shearing()

{

output();

printf("enter the shear value:");

scanf("%d",&sh);

printf("enter the fixed point:");

scanf("%d%d",&fx,&fy);

printf("enter the axis for shearing if x-axis then 1 if y-axis the 0:");

scanf("%d",&axis);

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

{

if(axis==1)

{

a[i][0]=a[i][0]+sh*(a[i][1]-fy);

}

else

{

a[i][1]=a[i][1]+sh*(a[i][0]-fx);

}

}

output();

delay(10);

menu();

}

void reflection()

{

output();

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

{

temp=a[i][0];

a[i][0]=a[i][1];

a[i][1]=temp;

}

output();

delay(10);

menu();

}

void main()

{

int gd=DETECT,gm;

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

menu();

getch();

}


Technicalsymposium.com-Free Study Materials PDF-Download




Technicalsymposium.com-Download All Study Notes PDF




Technicalsymposium.com-Free Live Support-Chat with Our Experts

Official Contact: +91-9245556793 (Whatsapp Message / SMS / Voice Call)


Our Expert team is ready to answer all your questions immediately-Feel free to speak in Tamil/English.

(Example:Events info/Lecture Notes/Off-Campus & All Jobs/Projects & All education information)

Working hrs (IST): (Morning: 10:00AM-3:00 PM) and (Evening:5:00 PM to 10:00 PM)

All Latest Question & Answer Page (FAQ)-Click here