-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCW.cpp
More file actions
39 lines (31 loc) · 705 Bytes
/
CCW.cpp
File metadata and controls
39 lines (31 loc) · 705 Bytes
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
#include <iostream>
using namespace std;
int abs(int a) { return a > 0 ? a : -a; }
struct Pos
{
int x, y, z;
};
Pos cross(Pos a, Pos b)
{
return {
(a.y * b.z - a.z * b.y),
- (a.x * b.z - a.z * b.x),
(a.x * b.y - a.y * b.x)
};
}
int main()
{
pair<int, int> a, b, c;
cin >> a.first >> a.second;
cin >> b.first >> b.second;
cin >> c.first >> c.second;
Pos vec1, vec2;
vec1 = {b.first - a.first, b.second - a.second, 0};
vec2 = {c.first - a.first, c.second - a.second, 0};
Pos result = cross(vec1, vec2);
if (result.z == 0)
cout << 0 << endl;
else
cout << result.z / abs(result.z) << endl;
return 0;
}