Page 142 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 142

Lab on Computer Graphics



                   Notes                 {
                                         case ‘1’:
                                           printf("
                                           Enter Scaling Ratio:- ");
                                           printf("
                                           Sx:- ");
                                           scanf("%f",&Sx);
                                           printf(" Sy:- ");
                                           scanf("%f",&Sy);
                                         for(i=0;i<3;i++)
                                         {
                                           Matrix[i][0]=Matrix[i][0]*Sx;
                                           Matrix[i][1]=Matrix[i][1]*Sy;
                                         }
                                         goto Menu;
                                         case ‘2’:
                                           printf(" Enter Translation [Relative]:- ");
                                           printf(" Tx:- ");
                                           scanf("%f",&Sx);
                                           printf("   Ty:- ");
                                           scanf("%f",&Sy);
                                         Matrix[2][0]=Matrix[2][0]+Sx;
                                         Matrix[2][1]=Matrix[2][1]+Sy;
                                         goto Menu;
                                         case ‘3’:
                                           printf("
                                           Enter Rotation Angle [Degree]:- ");
                                           scanf("%f",&Sx);
                                           Sx=(Sx*3.14)/180;
                                         Cos=cos(Sx);
                                         Sin=sin(Sx);
                                         for(i=0;i<=2;i++)
                                         {
                                           temp=Matrix[i][0]*Cos–Matrix[i][1]*Sin;
                                           Matrix[i][1]=Matrix[i][0]*Sin+Matrix[i][1]*Cos;
                                         Matrix[i][0]=temp;
                                         }
                                         goto Menu;
                                         case ‘4’:
                                           Matrix[1][1]=Matrix[1][1]*–1;
                                           printf("




        136                               LOVELY PROFESSIONAL UNIVERSITY
   137   138   139   140   141   142   143   144   145   146   147