diff options
author | hanemile <hanemile@protonmail.com> | 2019-01-23 16:23:17 +0100 |
---|---|---|
committer | hanemile <hanemile@protonmail.com> | 2019-01-23 16:23:17 +0100 |
commit | be1b1d3d486499e4a7488747fdc1fbd31f7a5a36 (patch) | |
tree | 8fc85ce0205c4d9490c7966ef3a30893bd7aa130 | |
parent | 1edf4e33d33629cf29f9eaed47b7c2f6729dc7ca (diff) |
added the recursion limit again
-rw-r--r-- | quadtree.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/quadtree.go b/quadtree.go index ca62afc..ebab528 100644 --- a/quadtree.go +++ b/quadtree.go @@ -62,6 +62,10 @@ func (n *Node) Subdivide() { // Insert inserts the given star into the Node or the tree it is called on func (n *Node) Insert(star Star2D) error { + if n.Boundry.Width < 1e-20 { + return fmt.Errorf("%s", "Max Recursion depth reached!") + } + // if the subtree does not contain a node, insert the star if n.Star == (Star2D{}) { @@ -105,7 +109,7 @@ func (n *Node) Insert(star Star2D) error { star = Star2D{} } - // fmt.Println("Done inserting %v, the tree noe looks like this: %v", star, n) + // fmt.Println("Done inserting %v, the tree looks like this: %v", star, n) return nil } |