6B. Write a program to perform 2D translation

 avatar
zoro
c_cpp
22 days ago
506 B
1
Indexable
Never
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int gd=DETECT,gm,x2,y2,x1,y1,x,y;
initgraph(&gd,&gm,”C:\\TurboC3\\BGI”);
cout<<”Enter the value of x1 and y1: “;
cin>>x1>>y1;
cout<<”Enter the value of x2 and y2: “;
cin>>x2>>y2;
line(x1,y1,x2,y2);
cout<<”Enter translating co-ordinates: “;
cin>>x>>y;
x1=(x1+x);
y1=(y1+y);
x2=(x2+x);
y2=(y2+y);
cout<<”Line after translating”;
line(x1,y1,x2,y2);
getch();
closegraph();
}
Leave a Comment