Circle with Radius 50mm, centre A(10,10) is to be Converted into
the Ellipse with Major axis 90mm and Minor axis 60mm. Find the total transformation.
Note:-
This a computer graphics 2D transformation program, in this program you have to find:-
1) Translation Matrix
2) Scaling Matrix
3) Resultant Matrix (Product of translation and scaling matrix).
Program:-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int trans[3][3]={{1,0,0},{0,1,0},{0,0,1}};
float scaling[3][3]={{1,0,0},{0,1,0},{0,0,1}};
float result[3][3],sx,sy;
int tx,ty,i,j,rad,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
printf("\nEnter the translation factors:");
scanf("%d%d",&tx,&ty);
printf("\nEnter the scaling factors:");
scanf("%f%f",&sx,&sy);
printf("\nEnter the co-ordinates of circle:");
scanf("%d%d",&x,&y);
printf("\nEnter the radius:");
scanf("%d",&rad);
ellipse(x,y,0,360,rad,rad);
trans[2][0]=tx;
trans[2][1]=ty;
sx=sx/100;
sy=sy/100;
scaling[0][0]=sx;
scaling[1][1]=sy;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
result[i][j]=trans[i][j]*scaling[i][j];
}
}
ellipse(x+150,y+150,0,360,result[0][0]*100,result[1][1]*100);
getch();
closegraph();
}
Output:-
the Ellipse with Major axis 90mm and Minor axis 60mm. Find the total transformation.
Note:-
This a computer graphics 2D transformation program, in this program you have to find:-
1) Translation Matrix
2) Scaling Matrix
3) Resultant Matrix (Product of translation and scaling matrix).
Program:-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int trans[3][3]={{1,0,0},{0,1,0},{0,0,1}};
float scaling[3][3]={{1,0,0},{0,1,0},{0,0,1}};
float result[3][3],sx,sy;
int tx,ty,i,j,rad,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
printf("\nEnter the translation factors:");
scanf("%d%d",&tx,&ty);
printf("\nEnter the scaling factors:");
scanf("%f%f",&sx,&sy);
printf("\nEnter the co-ordinates of circle:");
scanf("%d%d",&x,&y);
printf("\nEnter the radius:");
scanf("%d",&rad);
ellipse(x,y,0,360,rad,rad);
trans[2][0]=tx;
trans[2][1]=ty;
sx=sx/100;
sy=sy/100;
scaling[0][0]=sx;
scaling[1][1]=sy;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
result[i][j]=trans[i][j]*scaling[i][j];
}
}
ellipse(x+150,y+150,0,360,result[0][0]*100,result[1][1]*100);
getch();
closegraph();
}
Output:-
dd
ReplyDelete