Page 136 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 136
Lab on Computer Graphics
Notes printf("Enter the fixed pointn");
scanf("%d%d",&xa,&ya);
theta=(float)(270*(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 3:
printf("Enter the fixed pointn");
scanf("%d%d",&xa,&ya);
theta=(float)(180*(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;
}
break;
case 5:
detectgraph(&gm,&gr);
initgraph(&gm,&gr,"d:tcBGI");
rectangle(x,y,az,w);
printf("*******Shearing******nn");
printf("1.x-direction shearn2.y-direction shearnEnter your choice:n");
scanf("%d",&ch2);
130 LOVELY PROFESSIONAL UNIVERSITY