Reflection Program(CG)

//Write a program for Reflection of Triangle.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>

int main()
{
int gdriver=DETECT,gmode;
int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6;
    float theta;
initgraph(&gdriver,&gmode,"..//BGI");
cleardevice();
printf("\n Enter first  coordinates of triangle:");
scanf("%d%d",&x4,&y4);
printf("\n Enter second  coordinates of triangle:");
scanf("%d%d",&x5,&y5);
printf("\n Enter third  coordinates of triangle:");
scanf("%d%d",&x6,&y6);
x1=320+x4;
y1=240-y4;
x2=320+x5;
y2=240-y5;
x3=320+x6;
y3=240-y6;
getch();
cleardevice();
line(320,0,320,480);
line(0,240,640,240);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
y1+=2*y4;
y2+=2*y5;
y3+=2*y6;
printf("Traingle after Reflection :\n");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
x1-=2*x4;
y1=240-y4;
x2-=2*x5;
y2=240-y5;
x3-=2*x6;
y3=240-y6;
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
closegraph();
}


//this code is compile in Turbo c

Share this

Related Posts

Previous
Next Post »

Powered by Blogger.

Popular Posts