isLeft function

num isLeft(
  1. Position p1,
  2. Position p2,
  3. Position p3
)

Returns a positive value if p3 is to the left of the line from p1 to p2, negative if to the right, and 0 if collinear.

Implementation

num isLeft(Position p1, Position p2, Position p3) {
  return ((p2[0]! - p1[0]!) * (p3[1]! - p1[1]!) -
      (p3[0]! - p1[0]!) * (p2[1]! - p1[1]!));
}