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

Practical 9CGR

The document provides a C program for performing 2D reflection and shear transformations on a polygon using graphics.h library. It initializes a graphical window, draws a polygon, reflects it across a horizontal axis, and applies a shear transformation. The program utilizes color coding to differentiate between the original, reflected, and sheared polygons.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Practical 9CGR

The document provides a C program for performing 2D reflection and shear transformations on a polygon using graphics.h library. It initializes a graphical window, draws a polygon, reflects it across a horizontal axis, and applies a shear transformation. The program utilizes color coding to differentiate between the original, reflected, and sheared polygons.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical-No:-9

-Write a C program for 2D Reflection and Shear.

Code:-
#include <graphics.h>
#include <conio.h>

void main() {
int gd = DETECT, gm;
int poly[8] = {150, 100, 200, 50, 250, 100, 200, 150};
int reflected_poly[8],i;
int sheared_poly[8];
int shear_factor = 1;

initgraph(&gd, &gm, " ");


clrscr();

drawpoly(4, poly);
delay(1000);

for (i = 0; i < 8; i += 2) {
reflected_poly[i] = poly[i];
reflected_poly[i + 1] = 400 - poly[i + 1];
}

setcolor(RED);
drawpoly(4, reflected_poly);
delay(1000);

for (i = 0; i < 8; i += 2) {
sheared_poly[i] = poly[i] + shear_factor * poly[i + 1];
sheared_poly[i + 1] = poly[i + 1];
}

setcolor(BLUE);
drawpoly(4, sheared_poly);

getch();
closegraph();
}

Output:-

You might also like