public bool AddLeaf(OctreeLeaf leaf) { double x = leaf.getX(); double y = leaf.getY(); double z = leaf.getZ(); if (!this._bounds.InBound(x, y, z)) { return(false); } if (this._leafs.Count + 1 > this._capacity) { this._divide(); } if (this._innerNode) { for (int i = 0; i < 8; i++) { if (this._childs[i].AddLeaf(leaf)) { break; } } } else { this._leafs.Add(leaf); } return(true); }
public double getDistanceToCenter(OctreeLeaf oL) { double sum = 0.0d; sum += Math.Pow(oL.getX() - this.getXCenter(), 2); sum += Math.Pow(oL.getY() - this.getYCenter(), 2); sum += Math.Pow(oL.getZ() - this.getZCenter(), 2); return(Math.Sqrt(sum)); }