isOverlapping static method

bool isOverlapping(
  1. FreeHexagon hex1,
  2. FreeHexagon hex2
)

检查两个六边形是否重叠

Implementation

static bool isOverlapping(FreeHexagon hex1, FreeHexagon hex2) {
  final distance = math.sqrt(
    math.pow(hex1.center.dx - hex2.center.dx, 2) +
        math.pow(hex1.center.dy - hex2.center.dy, 2),
  );

  final minDistance = hex1.size + hex2.size;
  return distance < minDistance;
}