diff --git a/src/Handlers/IntersectionHandler.php b/src/Handlers/IntersectionHandler.php index 134154f..8c18cd0 100644 --- a/src/Handlers/IntersectionHandler.php +++ b/src/Handlers/IntersectionHandler.php @@ -41,10 +41,10 @@ private static function isRectangleIntersected(Item $firstItem, Item $secondItem $secondCx = $secondItem->getPosition()[$xAxis] + $secondDimension[$xAxis] / 2; $secondCy = $secondItem->getPosition()[$yAxis] + $secondDimension[$yAxis] / 2; - $ix = max($firstCx, $secondCx) - min($firstCx, $secondCx); - $iy = max($firstCy, $secondCy) - min($firstCy, $secondCy); + $ix = round(max($firstCx, $secondCx) - min($firstCx, $secondCx)); + $iy = round(max($firstCy, $secondCy) - min($firstCy, $secondCy)); - return $ix < ($firstDimension[$xAxis] + $secondDimension[$xAxis]) / 2 && $iy < ($firstDimension[$yAxis] + $secondDimension[$yAxis]) / 2; + return $ix < round(($firstDimension[$xAxis] + $secondDimension[$xAxis]) / 2) && $iy < round(($firstDimension[$yAxis] + $secondDimension[$yAxis]) / 2); } /**