/** * Определяет, пересикается ли текущий прямоугольник * с заданным по оси Y * * @param Rectangle $rect * @return boolean */ public function isIntersectsWithY(Rectangle $rect) { if ($rect->isNull() || $this->isNull()) { return false; } $top1 = $this->getTop(); $top2 = $rect->getTop(); if ($top1 < $top2) { return $top2 - $top1 < $this->getHeight(); } else { if ($top1 >= $top2) { return $top1 - $top2 < $rect->getHeight(); } } }