#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
struct s
{ int x,y ;
};
void main()
{ int n;
int gd= DETECT ,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
struct s inp[10],out[10];
printf("\n Enter the no
of vertices");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf ("%d%d",&inp[i].x&inp[i].y);
}
int a;
printf("\n Enter the
rotational angle");
scanf ("%d",&a);
a= a* (3.14/180);
for(i=0;i<n;i++)
{ out[i].x= (inp[i].x *
cos(a)) - (inp[i].y*sin(a));
out[i].y = (inp[i].x *
sin(a)) + (inp[i].y* cos(a));
}
inp[n]= inp[0];
out[n] = out[0];
for(i=0;i<n;i++)
{ setcolor(7);
line(inp[i].x,inp[i].y,inp[i+1].x,inp[i+1].y);
}
getch();
for(i=0;i<n;i++)
{ printf ("%d%d",out[i].x,out[i].y);
}
getch();
for(i=0;i<n;i++)
{
setcolor(5);
line(out[i].x,out[i].y,out[i+1].x,out[i+1].y);
}
getch();
closegraph();
}
No comments:
Post a Comment