1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include #include #include #include #include #include <math> float x1,y1,x2,y2,x,y,x3,y3,x4,y4,a; int ch; void main() { int gdriver = DETECT, gmode, errorcode; clrscr(); initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); cout<<"enter coordinates of line1:\n"; cin>>x1>>y1>>x2>>y2; cout<<"enter the angle of rotation:\n";cin>>a; cleardevice(); line(x1,y1,x2,y2); moveto(x2,y2); lineto(x1,y1); a=a*(3.14/180); x1=(x1*cos(a))-(y1*sin(a)); y1=(x1*sin(a))+(y1*cos(a)); x2=(x2*cos(a))-(y2*sin(a)); y2=(x2*sin(a))+(y2*cos(a)); cout<<"now hit a key to see rotation:"; getch(); moveto(x1,y1); lineto(x2,y2); moveto(x2,y2); lineto(x1,y1); getch(); closegraph(); } </math> |