diff --git a/Answers/Jaspal_1901010_code1 b/Answers/Jaspal_1901010_code1 new file mode 100644 index 0000000..ec74f77 --- /dev/null +++ b/Answers/Jaspal_1901010_code1 @@ -0,0 +1,31 @@ +#include +#include +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 ;} diff --git a/Answers/Jaspal_1901010_code2 b/Answers/Jaspal_1901010_code2 new file mode 100644 index 0000000..7a694b5 --- /dev/null +++ b/Answers/Jaspal_1901010_code2 @@ -0,0 +1,36 @@ +#include +#include +#include +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; +} diff --git a/Answers/jaspal_output1.JPG b/Answers/jaspal_output1.JPG new file mode 100644 index 0000000..d32e264 Binary files /dev/null and b/Answers/jaspal_output1.JPG differ diff --git a/Answers/jaspal_output2.JPG b/Answers/jaspal_output2.JPG new file mode 100644 index 0000000..0095e07 Binary files /dev/null and b/Answers/jaspal_output2.JPG differ