Program for Translation (CG)

// Write  a program for Translation Of Triangle.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,x1,x2,x3,y1,y2,y3,tx,ty;
initgraph(&gd,&gm,"..\\bgi");
printf("\nEnter the first Coordinate : ");
scanf("%d%d",&x1,&y1);
printf("\nEnter the second Coordinate : ");
scanf("%d%d",&x2,&y2);
printf("\nEnter the third Coordinate : ");
scanf("%d%d",&x3,&y3);
cleardevice();
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
cleardevice();
printf("\nEnter the Trasformation Factor : ");
scanf("%d%d",&tx,&ty);
x1=x1+tx;
x2=x2+tx;
x3=x3+tx;
y1=y1+ty;
y2=y2+ty;
y3=y3+ty;
cleardevice();
printf("\nTriangle After Trasformation :\n ");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
closegraph();
}

//This code is complie in turbo c.




Share this

Related Posts

Previous
Next Post »

Powered by Blogger.

Popular Posts