UNPKG

2d-quadtree

Version:

Quadtree for games and simulations

1,322 lines (282 loc) 13 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Quadtree</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Quadtree</h1> <section> <header> <h2> Quadtree </h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Quadtree"><span class="type-signature"></span>new Quadtree<span class="signature">(options)</span><span class="type-signature"></span></h4> <div class="description"> Quadtree contstructor function. Use to initialize the Quadtree. Also, whenever the quadtree splits, this constructor is used to initialize the new nodes of the quadtree. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The only options of concern to you: width, height, maxChildren, depth</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line61">line 61</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="canCollapse"><span class="type-signature"></span>canCollapse<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Helper method that determines if the quadtree should collapse </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line251">line 251</a> </li></ul></dd> </dl> <h4 class="name" id="collapse"><span class="type-signature"></span>collapse<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Collapses the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line219">line 219</a> </li></ul></dd> </dl> <h4 class="name" id="divide"><span class="type-signature"></span>divide<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Partitions the quadTree into 4 equal sized quadTrees. It also re-inserts all of the children that the leaf contained. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line172">line 172</a> </li></ul></dd> </dl> <h4 class="name" id="getChildCount"><span class="type-signature"></span>getChildCount<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> Returns the number of children in the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line284">line 284</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of children in the quadTree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="getChildren"><span class="type-signature"></span>getChildren<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> getChildren returns an array of all the children of the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line335">line 335</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> all the children of the quadTree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="getOrphanAndChildCount"><span class="type-signature"></span>getOrphanAndChildCount<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> getOrphanAndChildCount returns all rectangles that have been inserted into the quadtree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line305">line 305</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of all inserted objects in the quadtree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="getOrphanCount"><span class="type-signature"></span>getOrphanCount<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> getOrphanCount returns the number of orphans in the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line259">line 259</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> number of orphans in the quadTree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="getOrphans"><span class="type-signature"></span>getOrphans<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> getOrphans return all the orphans of the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line313">line 313</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> all the orphans of the quadTree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="getOrphansAndChildren"><span class="type-signature"></span>getOrphansAndChildren<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> getOrphansAndChildren returns an array of all the children and orphans of the quadTree </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line354">line 354</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> all the children and orphans of the quadTree </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="getQuadtreeCount"><span class="type-signature"></span>getQuadtreeCount<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> getQuadtreeCount returns the number of divisions within the quadtree. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line362">line 362</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of divisions within the quadtree. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="insert"><span class="type-signature"></span>insert<span class="signature">(An)</span><span class="type-signature"></span></h4> <div class="description"> Inserts an object into the quadTree </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>An</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">arbitrary object with rectangle properties (x, y, width, height)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="quadtree.js.html">quadtree.js</a>, <a href="quadtree.js.html#line85">line 85</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Quadtree.html">Quadtree</a></li></ul><h3>Global</h3><ul><li><a href="global.html#forceObjectWithinBounds">forceObjectWithinBounds</a></li><li><a href="global.html#getBounds">getBounds</a></li><li><a href="global.html#hasRectProps">hasRectProps</a></li><li><a href="global.html#isIntersecting">isIntersecting</a></li><li><a href="global.html#isWithinBounds">isWithinBounds</a></li><li><a href="global.html#rectPrototype">rectPrototype</a></li><li><a href="global.html#remove">remove</a></li><li><a href="global.html#setQuadrant">setQuadrant</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Tue Aug 04 2015 14:09:02 GMT-0400 (Eastern Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>