Scaling A Polygon In 2-D

09:20 0 Comments A+ a-

PROGRAM:



#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
//rotate a polygon
void main()
{
clrscr();
int gd=DETECT,gm,sx,sy,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(10);
cout<<"Enter x1 & y1 values: ";
cin>>x1>>y1;
cout<<"Enter x2 & y2 values: ";
cin>>x2>>y2;
cout<<"Enter x3 & y3 values: ";
cin>>x3>>y3;
cout<<"Enter scale in x and y: ";
cin>>sx>>sy;
x4=x1*sx;
y4=y1*sy;
x5=x2*sx;
y5=y2*sy;
x6=x3*sx;
y6=y3*sy;
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
delay(100);
line(x4,y4,x5,y5);
line(x5,y5,x6,y6);
line(x6,y6,x4,y4);
getch();
}