insideOrOutsideOfLine static method

int insideOrOutsideOfLine(
  1. Offset pre,
  2. Offset center,
  3. Offset next
)

判断某个点是在在两个点连线的里边还是外边

Implementation

static int insideOrOutsideOfLine(Offset pre, Offset center, Offset next) {
  final slope1 = calculateSlope(pre, next);
  final slope2 = calculateSlope(center, next);
  if (slope1 > slope2) {
    return 1; //里边
  } else if (slope1 < slope2) {
    return -1;
  } //外边
  return 0; //相等
}