PHP code example of michalsanger / quadtree

1. Go to this page and download the library: Download michalsanger/quadtree library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

michalsanger / quadtree example snippets


use \Quadtree\Quadtree;
use \Quadtree\Geometry\Bounds;
use \Quadtree\Geometry\Point;

$qtBounds = new Bounds(1024, 1024);
$qt = new Quadtree($qtBounds);

$qt->insert(new Bounds(300, 200)); // TRUE
$qt->insert(new Bounds(100, 50, 20, 10)); // FALSE
$qt->insert(new Point(250, 100)); // FALSE
$qt->insert(new Point(2000, 500)); // FALSE
$qt->insert(new Point(299, 199)); // TRUE