-
Notifications
You must be signed in to change notification settings - Fork 1
/
two-dimentional-scaling.cpp
55 lines (46 loc) · 1.28 KB
/
two-dimentional-scaling.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <graphics.h>
#include <bits/stdc++.h>
using namespace std;
void draw(vector<int> x, vector<int> y)
{
int n = x.size();
for (int i = 0; i < n; i++)
{
line(x[i], y[i], x[(i + 1) % n], y[(i + 1) % n]);
}
}
void scale(vector<int> &x, vector<int> &y, int n, int sfx, int sfy)
{
for (int i = 0; i < n; i++)
{
x[i] = x[i] * sfx;
y[i] = y[i] * sfy;
}
}
int main()
{
int n; //... Total vertex of the polygon
cin >> n;
vector<int> x(n), y(n); //... (x,y) coordinates of polygon vertex points
for (int i = 0; i < n; i++)
{
cin >> x[i] >> y[i];
}
int sfx, sfy; //... Scaling factors
cin >> sfx >> sfy;
int gd = DETECT, gm = DETECT;
initgraph(&gd, &gm, "");
setcolor(WHITE);
draw(x, y); //... The polygon before scaling
scale(x, y, n, sfx, sfy); //... Applying geometric scaling
setcolor(YELLOW);
draw(x, y); //... The polygon after scaling
getch();
closegraph();
return 0;
}
/*//... Sample Input-Output:
___________________________________________________________________________________________________________________________________________________________________________________________________________________________
Input:
4 100 100 100 150 150 150 150 100 2 2
*///...