CG 4
CG 4
#include <graphics.h>
#include <cmath>
class POLYGON {
private:
public:
};
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cout << "\n\n\t\tEnter (x,y) coordinate of point P" << i << ": ";
cout << p[i][0] << "\t" << p[i][1] << "\t" << p[i][2] << endl;
return n;
if (i < n - 1) {
line(p[i][0] + 320, -p[i][1] + 240, p[i + 1][0] + 320, -p[i + 1][1] + 240);
} else {
delay(3000);
if (i < n - 1) {
line(p[i][0] + 320, -p[i][1] + 240, p[i + 1][0] + 320, -p[i + 1][1] + 240);
} else {
// Translation matrix
Trans_result[i][j] = 0;
draw_poly(Trans_result, n);
int type;
sinAngle = sin(angle);
cosAngle = cos(angle);
// Rotation matrix
Rotation_result[i][j] = 0;
}
cout << "\n\n\t\tPolygon after Rotation...";
draw_polyfloat(Rotation_result, n);
// Scaling matrix
Scaling_result[i][j] = 0;
int main() {
int n, p[10][3];
POLYGON p1;
n = p1.accept_poly(p);
p1.draw_poly(p, n);
int ch;
do {
cout << "\n\n\t\t1. Translation \n\n\t\t2. Scaling \n\n\t\t3. Rotation \n\n\t\t4. Exit";
switch (ch) {
case 1:
p1.translation(p, n);
break;
case 2:
p1.scaling(p, n);
break;
case 3:
p1.rotation(p, n);
break;
case 4:
exit(0);
default:
} while (1);
return 0;
}
OUTPUT :