You are on page 1of 1

#include<stdio.

h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void main()
{
float x1,x2,y1,On,y2,xc,yc,x11,y11,x22,y22,O,t;
int gd=0,gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("enter the end points of line:");
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
printf("enter the angle of rotation:");
scanf("%f",&t);
line(0,240,640,240);
line(320,0,320,480);
line(320+x1,240-y1,320+x2,240-y2);
getch();
xc=(x1+x2)/2;
yc=(y1+y2)/2;
for(On=0;On<=t;On++)
{
cleardevice();
line(0,240,640,240);
line(320,0,320,480);
O=On*(3.14/180);
x11=x1*cos(O)-y1*sin(O)+xc*(1-cos(O))+yc*sin(O);
y11=x1*sin(O)+y1*cos(O)-xc*sin(O)+yc*(1-cos(O));
x22=x2*cos(O)-y2*sin(O)+xc*(1-cos(O))+yc*sin(O);
y22=x2*sin(O)+y2*cos(O)-xc*sin(O)+yc*(1-cos(O));
line(320+x11,240-y11,320+x22,240-y22);
delay(5);
}
getch();
}

You might also like