Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- #include<math.h>
- #include<graphics.h>
- void main()
- {
- clrscr;
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"c:\\tc\\bgi");
- int x1,x2,y1,y2,a[3][5],j,b[3][3],c[3][5];
- cout<<"enter the 1st diagnol coordinates of rectangle:\n";
- cin>>x1>>y1;
- cout<<"\n enter the 2nd diagnol coordinates : \n";
- cin>>x2>>y2;
- rectangle(x1,y1,x2,y2);
- cout<<"\n the matrix for rectangle : \n";
- a[1][1]=x1;
- a[1][2]=x2;
- a[1][3]=x2;
- a[1][4]=x1;
- a[2][1]=y1;
- a[2][2]=y1;
- a[2][3]=y2;
- a[2][4]=y2;
- for(int i=1;i<3;i++)
- {
- for(j=1;j<5;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<"\n";
- }
- b[1][1]=2;
- b[1][2]=0;
- b[2][1]=0;
- b[2][2]=3;
- cout<<"\n the scaling matrix:\n";
- for(i=1;i<3;i++)
- {
- for(j=1;j<3;j++)
- {
- cout<<b[i][j]<<"\t";
- }
- cout<<"\n";
- }
- for(i=1;i<3;i++)
- {
- for(j=1;j<5;j++)
- {
- c[i][j]=0;
- for(int k=1;k<3;k++)
- {
- c[i][j]+=b[i][k]*a[k][j];
- }
- }
- cout<<"\n the transformed matrix \n";
- for(i=1;i<3;i++)
- {
- for(j=1;j<5;j++)
- {
- cout<<c[i][j]<<"\t";
- }
- cout<<"\n";
- }
- rectangle(c[1][1],c[2][1],c[1][3],c[2][3]);
- getch();
- closegraph();
- }
- }
Add Comment
Please, Sign In to add comment