lib/qtree.js
// put an object to this node
put an object to this node
put an object to this node
function put(node, obj) {
        if( node.n.length == 0 ) {
            node.c.push(obj)
            if( node.c.length > maxc ) {
                var w2 = node.width / 2
                var h2 = node.height / 2
                node.n.push(createnode(node.x, node.y, w2, h2),
                            createnode(node.x + w2, node.y, w2, h2),
                            createnode(node.x, node.y + h2, w2, h2),
                            createnode(node.x + w2, node.y + h2, w2, h2))
                for( var ci = 0; ci < node.c.length; ci++ )
                    put_to_nodes(node, node.c[ci])
                node.c = []
            }
        } else
            put_to_nodes(node, obj)
    }
function put ( node , obj ) { if ( node . n . length == 0 ) { node . c . push ( obj ) if ( node . c . length > maxc ) { var w2 = node . width / 2 var h2 = node . height / 2 node . n . push ( createnode ( node . x , node . y , w2 , h2 ) , createnode ( node . x + w2 , node . y , w2 , h2 ) , createnode ( node . x , node . y + h2 , w2 , h2 ) , createnode ( node . x + w2 , node . y + h2 , w2 , h2 ) ) for ( var ci = 0 ; ci < node . c . length ; ci ++ ) put_to_nodes ( node , node . c [ ci ] ) node . c = [ ] } } else put_to_nodes ( node , obj ) }
put an object to this node
put an object to this node
// subdivide