C++ PROGRAM TO IMPLEMENT THE CONCEPT OF REFLEXION

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF REFLEXION

CODE:

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

void show(float a[][3]){

float xm,ym;

int i=0;

xm=getmaxx()/2;

ym=getmaxy()/2;

while(i<2){

line(xm+a[i][0],ym-a[i][1],xm+a[i+1][0],ym-a[i+1][1]);

i++;

}

i=2;


line(xm+a[i][0],ym-a[i][1],xm+a[0][0],ym-a[0][1]);

setcolor(RED);

line(0,ym,xm*2,ym);

line(xm,0,xm,ym*2);

setcolor(BLUE);

}

void matmul(float b[][3],float a[][3],float c[][3]){

int i,j,m;

for(i=0;i<3;i++){

for(j=0;j<3;j++){

c[i][j]=0;

}

}

for(i=0;i<3;i++){

for(j=0;j<3;j++){

for(m=0;m<3;m++){

c[i][j]=c[i][j]+(a[i][m]*b[m][j]);

}

}

}

}

void ref(float a[][3]){

float b[10][3],c[10][3];

int i=0,j;

show(a);

for(i=0;i<3;i++){

for(j=0;j<3;j++){

b[i][j]=0;

if(i==j)

b[i][j]=1;

}

}

b[1][1]=-1;

matmul(b,a,c);

setcolor(YELLOW);

show(c);

}

int main(){

int gdriver=DETECT,gmode;

float a[10][3];

initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");

printf("Enter the coordinates of triangle:\n");

for(int k=0;k<3;k++){

printf("Enter the coordinates:\n",k+1);

scanf("%f%f",&a[k][0],&a[k][1]);

a[k][2]=1;

}

setcolor(WHITE);

show(a);

ref(a);

getch();

closegraph();

return 0;

}


OUTPUT:


Enter the coordinates of triangle:

Enter the coordinates:

50 50 100 150 150 50

___________________________________________________________________



 

Comments

Popular posts from this blog

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF FIXED SCALING

C++ PROGRAM TO IMPLEMEMT THE CONCEPT OF FLOODFILL ALGORITHM