UNKNOWN //************************************** // Name: Two Dimensional 2D composite Transformations // Description:To perform 2d composite transformation on objects in C // By: Rekha Ram Chaudhary // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.13854/lngWId.3/qx/vb/scripts/ShowCode.htm //for details. //************************************** #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<math.h> #include<stdlib.h> void menu(); void input(); void input1(); void output(); void output1(); void shearing(); void reflection(); inta[10][10],b[10][10],b1[10][10],diff,i,j,x,option,temp,angle,tx,ty,fx,fy,sh,k,n, axis,y; float sx,sy; void menu() { printf("menu\n"); printf("0.draw\n"); printf("1.shearing\n"); printf("2.reflection\n"); printf("3.exit\n"); printf("enter the choice:"); scanf("%d",&option); switch(option) { case 0: input(); menu(); break; case 1 : shearing(); break; case 2: reflection(); break; case 3: exit(0); break; } input(); } void input() { printf("enter the number of vertices:" ); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the coordinates:"); scanf("%d%d%d%d",&a[i][0],&a[i][1],&a[i+1][0],&a[i+1][1]); } } void output() { cleardevice(); for(i=0;i<n;i++) { line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]); } for(i=0;i<n;i++) { b[i][0]=0; b[i][1]=0; } } void input1() { cleardevice(); for(i=0;i<n;i++) { line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]); } } void output1() { cleardevice(); for(i=0;i<n;i++) { line(b[i][0],b[i][1],b[i+1][0],b[i+1][1]); } } void shearing() { output(); printf("enter the shear value:"); scanf("%d",&sh); printf("enter the axis for shearing if x-axis then 1 if y-axis the 0:"); scanf("%d",&axis); if(axis==1) { for(i=0;i<=n;i++) { if(i!=0 && i!=3) { b[i][0]=a[i][0]+sh; b[i][1]=a[i][1]; } else { b[i][0]=a[i][0]; b[i][1]=a[i][1]; } } } else { for(i=0;i<=n;i++) { if(i!=1) { b[i][1]=a[i][1]+sh; b[i][0]=a[i][0]; } else { b[i][0]=a[i][0]; b[i][1]=a[i][1]; } } } output1(); delay(10); menu(); } void reflection() { output(); diff=a[1][1]-a[0][1]; for(i=0;i<=n;i++) { if(i==0||i==3) { b[i][0]=a[i][0]; b[i][1]=a[i][1]+(2*diff)+10; } else { b[i][0]=a[i][0]; b[i][1]=a[i][1]+10; } } for(i=0;i<n;i++) { line(b[i][0],b[i][1],b[i+1][0],b[i+1][1]); } menu(); } void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); menu(); getch(); }