Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Ans-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <graphics.h> int main( ){
int gd=DETECT,gm;
int t[3][3]={1,0,0,0,1,0,0,0,1},a[3][3],r[3][3]={0},i,j,k;
printf("Enter value of x1 and y1: "); scanf("%d %d", &a[0][0], &a[0][1]);
printf("Enter value of x2 and y2: "); scanf("%d %d", &a[1][0], &a[1][1]);
printf("Enter value of x3 and y3: "); scanf("%d %d", &a[2][0], &a[2][1]);
printf("Enter value of tx and ty: "); scanf("%d %d", &t[2][0], &t[2][1]); a[0][2]=a[1][2]=a[2][2]=1;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
for(k=0;k<3;k++){
r[i][j] = r[i][j] + (a[i][k]*t[k][j]);
}
}
}
initgraph(&gd,&gm,"NULL"); line(a[0][0],a[0][1],a[1][0],a[1][1]);
line(a[1][0],a[1][1],a[2][0],a[2][1]);
line(a[0][0],a[0][1],a[2][0],a[2][1]);
outtext("- - - Before Translation - - -"); delay(5000);
cleardevice(); line(r[0][0],r[0][1],r[1][0],r[1][1]);
line(r[1][0],r[1][1],r[2][0],r[2][1]);
line(r[0][0],r[0][1],r[2][0],r[2][1]);
outtext("- - - After Translation - - -"); delay(5000);closegraph( );return 0 ;}
31 changes: 31 additions & 0 deletions ans-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void scaling(int x1,int y1,int x2,int y2,int x3,int y3)
{ int sx,sy,xn1,yn1,xn2,xn3,yn3,yn2,gd=0,gm;
printf("enter the scaling vector\n");
scanf("%d%d",&sx,&sy);
xn1=x1*sx; yn1=y1*sy;
xn2=x2*sx; yn2=y2*sy;
xn3=x3*sx; yn3=y3*sy;
initgraph(&gd,&gm,"");
setcolor(RED); line(x1,y1,x2,y2);
setcolor(RED);
line(x1,y1,x3,y3);
setcolor(RED);
line(x2,y2,x3,y3);
delay(600);
setcolor(YELLOW);
line(xn1,yn1,xn2,yn2);
setcolor(YELLOW);
line(xn1,yn1,xn3,yn3);
setcolor(YELLOW);
line(xn2,yn2,xn3,yn3);
delay(600);
}
int main( ){
int ch,x1,y1,x2,y2,x3,y3;
printf("enter the vertex co-ordinates of triangle\n");
scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3); scaling(x1,y1,x2,y2,x3,y3); delay(9999);
return 0;
}
Binary file added ans-2 output.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ans1 output.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.