0% found this document useful (0 votes)
126 views2 pages

Practical No-7 CG

The document describes a C++ program to perform reflection of a line about the x-axis and y-axis. It takes user input for the coordinates of the original line, draws the line, reflects it about the x-axis by multiplying the y-coordinates by -1, and labels it. It then reflects the line about the y-axis by multiplying the x-coordinates by -1 and labels that reflection. The program outputs the original line and its reflections about the two axes.

Uploaded by

Meena Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views2 pages

Practical No-7 CG

The document describes a C++ program to perform reflection of a line about the x-axis and y-axis. It takes user input for the coordinates of the original line, draws the line, reflects it about the x-axis by multiplying the y-coordinates by -1, and labels it. It then reflects the line about the y-axis by multiplying the x-coordinates by -1 and labels that reflection. The program outputs the original line and its reflections about the two axes.

Uploaded by

Meena Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No.

- 7

Aim: - To perform reflection of a point about a line y= mx+c.


#include<iostream.h>
#include<conio.h>
#include<graphics.h>

void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
int x1,y1,x2,y2;
cout<<"Enter the coordinates of the line\n";
cin>>x1>>y1>>x2>>y2;
int m=getmaxx();
int n=getmaxy();
setcolor(6);
line(x1,y1,x2,y2);
outtextxy(x1,y1+10,"Original Object");
setcolor(4);
line((m/2),0,(m/2),n);
line(0,(n/2),m,(n/2));
setcolor(3);
int c=(n/2)-y1;
int d=(n/2)-y2;
y2=y2+(d*2);
y1=y1+(c*2);
line(x2,y2,x1,y1);
outtextxy(x1,y1+10,"Reflection along X-axis");
setcolor(9);
int a=(m/2)-x1;

www.ahirlabs.com 1
int b=(m/2)-x2;
x1=x1+(a*2);
x2=x2+(b*2);
line(x1,y1,x2,y2);
outtextxy(x2-20,y2+10,"Reflection along Y-axis");
getch();
closegraph();
}

OUTPUT: -

www.ahirlabs.com 2

You might also like