1: <?php
2:
3: namespace Quadtree;
4:
5: class CollisionDetector implements \Quadtree\ICollisionDetector
6: {
7: /**
8: * @param \Quadtree\Geometry\Bounds $bounds
9: * @param \Quadtree\Insertable $item
10: * @return boolean
11: */
12: public function intersects(Geometry\Bounds $bounds, Insertable $item)
13: {
14: return $bounds->getBounds()->intersects($item->getBounds());
15: }
16:
17: /**
18: * @param \Quadtree\Insertable[] $insertedItems
19: * @param \Quadtree\Insertable $item
20: * @return boolean
21: */
22: public function collide(array $insertedItems, Insertable $item) {
23: foreach ($insertedItems as $insertedItem) {
24: /* @var $insertedItem Insertable */
25: if ($insertedItem->getBounds()->intersects($item->getBounds())) {
26: return TRUE;
27: }
28: }
29: return FALSE;
30: }
31: }
32: