0% found this document useful (0 votes)
414 views

Practical - 17 AIM: Write A Program To Implement Reflection. Program

The program implements reflection of a triangle by getting coordinates of three points of a triangle from the user, drawing the triangle, then calculating the reflection by getting the maximum y-coordinate, adding a distance, and reflecting all y-coordinates about that new line. It then redraws the reflected triangle. A second program implements shearing of a square by drawing the square, then redrawing it after shifting the x-coordinates of two vertices by 30 units to shear the shape.

Uploaded by

anshumanchandel
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)
414 views

Practical - 17 AIM: Write A Program To Implement Reflection. Program

The program implements reflection of a triangle by getting coordinates of three points of a triangle from the user, drawing the triangle, then calculating the reflection by getting the maximum y-coordinate, adding a distance, and reflecting all y-coordinates about that new line. It then redraws the reflected triangle. A second program implements shearing of a square by drawing the square, then redrawing it after shifting the x-coordinates of two vertices by 30 units to shear the shape.

Uploaded by

anshumanchandel
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 17

AIM: Write a program to implement reflection.


Program:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,x1,dis,y1,x2,y2,x3,y3,y11,y22,y33,g;
char r;
initgraph(&gd,&gm,"..//BGI");
cleardevice();
printf("Enter the coordinates of triangle");
printf("x1,y1 : ");
scanf("%d%d",&x1,&y1);
printf("x2,y2 : ");
scanf("%d%d",&x2,&y2);
printf("x3,y3 : ");
scanf("%d%d",&x3,&y3);
printf("enter the distance from x axis ");
scanf("%d",&dis);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
if(y1>y2)
{
if(y1>y3)
g=y1;
else
g=y3;
}
OUTPUT:
else
{
if(y2>y3)
g=y2;
else
g=y3;
}
g=g+dis;
y11=g+(g-y1);
y22=g+(g-y2);
y33=g+(g-y3);
line(x1,y11,x2,y22);
line(x2,y22,x3,y33);
line(x3,y33,x1,y11);
getch();
closegraph();
}

PRACTICAL 18
AIM: Write a program to implement Shearing.
Program:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,a,b,c,d,e,f,g,h;
initgraph(&gd,&gm,"..//BGI");
a=100;
b=100;
c=200;
d=100;
e=100;
f=200;
g=200;
h=200;
printf("before shearing");
line(a,b,c,d);
line(a,b,e,f);
line(e,f,g,h);
line(c,d,g,h);
delay(10000);
cleardevice();
printf("after shearing");
a=a+30;
c=c+30;
line(a,b,c,d);
line(a,b,e,f);
line(e,f,g,h);
line(c,d,g,h);
getch();
closegraph();
}
OUTPUT:

You might also like