1 //compute orientation of an ordered triplet of points in the plane
2 /*
3 * counterclockwise, clockwise, colinear
4 */
5
6 #include<bits/stdc++.h>
7
8 using namespace std;
9
10 struct Point
11 {
12 int x,y;
13 };
14
15 /*
16 use slope to calculate, note the orientation of (p,q,r) is converse to (r,q,p)
17 0--->colinear
18 1--->counterclockwise
19 2--->clockwise
20 */
21
22 int calOrientation(Point p1,Point p2,Point p3)
23 {
24 int val=(p3.y-p2.y)*(p2.x-p1.x)-(p2.y-p1.y)*(p3.x-p2.x);
25 if(val==0)
26 return 0;
27 return val>0?1:2;
28 }