#include #include #include #include #define lin(a,b,c,d) line(320+(a),240-(b),320+(c),240-(d)) #define tr(x,y) x*cos(t)-y*sin(t)+tx,x*sin(t)+y*cos(t)+ty #define th(x,y) tr((x-tx),(y-ty)) #define ts1(x,y) x+xsh*y,y #define ts2(x,y) x,ysh*x+y #define ts3(x,y) x+xsh*y,y*ysh+x void rectangl(int a,int b,int c,int d,int e,int f,int g,int h) { lin(a,b,c,d); lin(c,d,e,f); lin(e,f,g,h); lin(g,h,a,b); } main() { int left,top,right,bottom,tx,ty,gd=DETECT,gm,xsh,ysh; double t; initgraph(&gd,&gm,"c:\\tcpp30\\bgi"); lin(-320,0,320,0); lin(0,-240,0,240); printf("Enter topleft x and y:"); scanf("%d%d",&left,&top); printf("Enter bottomright x and y:"); scanf("%d%d",&right,&bottom); rectangl(left,top,right,top,right,bottom,left,bottom); printf("Enter angle of rotation:"); scanf("%lf",&t); t*=M_PI/180; printf("Enter translation x and y:"); scanf("%d%d",&tx,&ty); rectangl(tr(left,top),tr(right,top),tr(right,bottom),tr(left,bottom)); printf("Enter arb. point x and y:"); scanf("%d%d",&tx,&ty); printf("Enter angle of rotation:"); scanf("%lf",&t); t*=M_PI/180; rectangl(th(left,top),th(right,top),th(right,bottom),th(left,bottom)); printf("Enter shear x and y:"); scanf("%d%d",&xsh,&ysh); rectangl(ts1(left,top),ts1(right,top),ts1(right,bottom),ts1(left,bottom)); rectangl(ts2(left,top),ts2(right,top),ts2(right,bottom),ts2(left,bottom)); rectangl(ts3(left,top),ts3(right,top),ts3(right,bottom),ts3(left,bottom)); getch(); return 0; }