fenwick tree

Orientation

Tells whether a point lies to the left or right of a directed line, or on the line itself.

ab +1 · left −1 · right 0 · on line

Implementation

Uses: Point
template<class T>
int orientation(Point<T> a, Point<T> b, Point<T> p) {
  T turn = cross(b - a, p - a);
  return (turn > 0) - (turn < 0);
}

Interface

Operation Description Constraints Time
orientation(a, b, p) Looking from a toward b, returns +1 if p is to the left, -1 if to the right, or 0 if p is on the line. a and b are distinct. O(1){O(1)}