Page 135 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 135

Unit 8: Implementing of Scaling in 2D Transformation



                     break;                                                                       Notes
                     case 3:
                     detectgraph(&gm,&gr);
                     initgraph(&gm,&gr,"d:tcBGI");
                     rectangle(x,y,az,w);
                     printf("********Scaling*******nn");
                     printf("Enter the value of scaling factor:n");
                     scanf("%f%f",&sx,&sy);
                     x1=x*sx;
                     y1=y*sy;
                     az1=az*sx;
                     w1=w*sy;
                     rectangle(x1,y1,az1,w1);
                     break;
                     case 4:
                     detectgraph(&gm,&gr);
                     initgraph(&gm,&gr,"d:tcBGI");
                     rectangle(x,y,az,w);
                     printf("*******Reflection*********n");
                     printf("1.About  x–axisn2.About  y-axisn3.About  both  axisnEnter  your
                     choice:n");
                     scanf("%d",&ch1);
                     switch(ch1)
                     {
                     case 1:
                     printf("Enter the fixed pointn");
                     scanf("%d%d",&xa,&ya);
                     theta=(float)(90*(3.14/180));
                     for(i=0;i<4;i++)
                     {
                     a1[i]=(xa+((a[i]–xa)*cos(theta)–(–b[i]–ya)*sin(theta)));
                     b1[i]=(ya+((a[i]–xa)*sin(theta)+(–b[i]–ya)*cos(theta)));
                     }
                     for(i=0;i<4;i++)
                     {
                     if(i!=3)
                     line(a1[i],b1[i],a1[i+1],b1[i+1]);
                     else
                     line(a1[i],b1[i],a1[0],b1[0]);
                     }
                     break;
                     case 2:


                                             LOVELY PROFESSIONAL UNIVERSITY                                   129
   130   131   132   133   134   135   136   137   138   139   140