polygonToPolygon static method

bool polygonToPolygon(
  1. PolygonShape a,
  2. PolygonShape b
)

Implementation

static bool polygonToPolygon(PolygonShape a, PolygonShape b) {
  if (!rectToRect(a.rect, b.rect)) return false;

  final pointsA = a.points.toList()..add(a.points.first);
  final pointsB = b.points.toList()..add(b.points.first);
  for (var i = 0; i < pointsA.length - 1; i++) {
    final pointA = pointsA[i];
    final pointB = pointsA[i + 1];

    if (!isLinesShadowOver(
        pointA, pointB, b.rect.leftTop, b.rect.rightBottom)) {
      continue;
    }

    for (var j = 0; j < pointsB.length - 1; j++) {
      final pointC = pointsB[j];
      final pointD = pointsB[j + 1];

      if (!isLinesShadowOver(pointA, pointB, pointC, pointD)) {
        continue;
      }

      if (isLinesOver(pointA, pointB, pointC, pointD)) {
        return true;
      }
    }
  }

  return false;
}