Rectangle Rotation In 2-D

09:18 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,x1,y1,x2,y2,x3,y3,x4,y4;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(10);
cout<<"Enter x1 & y1 value: ";
cin>>x1>>y1;
cout<<"Enter x2 & y2 value: ";
cin>>x2>>y2;
rectangle(x1,y1,x2,y2);
rectangle(x2,y2,x1,y1);
x3=x1*cos(90)+y1*sin(90);
y3=x1*sin(90)-y1*cos(90);
x4=x2*cos(90)+y2*sin(90);
y4=x2*sin(90)-y2*cos(90);
rectangle(x3,y3,x4,y4);
rectangle(x4,y4,x3,y3);
getch();
}