Class BarnesHutQuadTree<T>


  • public class BarnesHutQuadTree<T>
    extends Object
    A QuadTree that can gather combined forces from visited nodes. Inspired by http://arborjs.org/docs/barnes-hut http://www.cs.princeton.edu/courses/archive/fall03/cs126/assignments/barnes-hut.html https://github.com/chindesaurus/BarnesHut-N-Body
    Author:
    Tom Nelson
    • Constructor Detail

      • BarnesHutQuadTree

        public BarnesHutQuadTree()
    • Method Detail

      • getBounds

        public Rectangle getBounds()
        the bounds of this quad tree
        Returns:
        the bounds of the entire quadtree
      • getRoot

        public Node<T> getRoot()
        Returns:
        the root Node of this tree
      • clear

        public void clear()
      • applyForcesTo

        public void applyForcesTo​(ForceObject<T> visitor)
        Parameters:
        visitor - passed ForceObject will visit nodes in the quad tree and accumulate their forces
      • rebuild

        public void rebuild​(Collection<T> elements,
                            Function<T,​Point> locations)
        rebuild the quad tree with the nodes and location mappings of the passed LayoutModel
        Parameters:
        locations - - mapping of elements to locations