• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 22nd, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. point* skala(point* coordinates, int size) {
2.     double x, y, skala, A, aS, Ax = 0, Ay = 0, ax=0, ay=0;
3.     point* cord = new point[size];
4.     int kon=0;
5. /*  cout << "Podaj wzgledem ktorego punktu mam obliczyc skale x: ";
6.     cin >> x;
7.     cout << "y: ";
8.     cin >> y;*/
9.     cout << "Podaj wspolczynnik skali w procentach(przyklad 70%= 0.7): ";
10.     cin >> skala;
11.
12.     for (int i = 0; i < size; i++) {
13.         Ax = Ax + coordinates[i].x;
14.         Ay = Ay + coordinates[i].y;
15.     }
16.     Ax = Ax / size;
17.     Ay = Ay / size;
18.
19.     cout << "Nowy srodek: " << Ax << " " << Ay << endl;
20.
21.     for (int i = 0; i < size; i++) {
22.         cord[i].x = coordinates[i].x * skala;
23.         cord[i].y = coordinates[i].y * skala;
24.     }
25.     for (int i = 0; i < size; i++) {
26.         ax = ax + cord[i].x;
27.         ay = ay + cord[i].y;
28.     }
29.     ax = ax / size;
30.     ay = ay / size;
31.
32.     cout << "nowy srodek: " << ax << " " << ay << endl;
33.
34.     ax = ax - Ax;
35.     ay = ay - Ay;
36.
37.     cout << "nowy srodek: " << ax << " " << ay << endl;
38.
39. /*  for (int i = 0; i < size; i++) {
40.         coordinates[i].x = coordinates[i].x + ax;
41.         coordinates[i].y = coordinates[i].y + ay;
42.     }*/
43.
44.     for (int i = 0; i < size; i++) {
45.         if (coordinates[i].x < ax && coordinates[i].y < ay) {
46.             coordinates[i].x = coordinates[i].x - ax;
47.             coordinates[i].y = coordinates[i].y - ay;
48.             cout << i << "<<" << endl;
49.         }
50.         if (coordinates[i].x < ax && coordinates[i].y > ay) {
51.             coordinates[i].x = coordinates[i].x - ax;
52.             coordinates[i].y = coordinates[i].y + ay;
53.             cout << i << "<>" << endl;
54.         }
55.         if (coordinates[i].x > ax && coordinates[i].y > ay) {
56.             coordinates[i].x = coordinates[i].x + ax;
57.             coordinates[i].y = coordinates[i].y + ay;
58.             cout << i << ">>" << endl;
59.         }
60.         if (coordinates[i].x > ax && coordinates[i].y < ay) {
61.             coordinates[i].x = coordinates[i].x + ax;
62.             coordinates[i].y = coordinates[i].y - ay;
63.             cout << i << "><" << endl;
64.         }
65.         if (coordinates[i].x == ax && coordinates[i].y == ay) {
66.         }
67.         if (coordinates[i].x == ax && coordinates[i].y > ay) {
68.             coordinates[i].y = coordinates[i].y + ay;
69.         }
70.         if (coordinates[i].x == ax && coordinates[i].y < ay) {
71.             coordinates[i].y = coordinates[i].y - ay;
72.         }
73.         if (coordinates[i].x > ax&& coordinates[i].y == ay) {
74.             coordinates[i].x = coordinates[i].y + ax;
75.         }
76.         if (coordinates[i].x < ax && coordinates[i].y == ay) {
77.             coordinates[i].x = coordinates[i].y - ax;
78.         }
79.     }
80.
81.     getchar(); getchar();
82.     return coordinates;
83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top