/// <summary> /// Gets index of the quadrant where the given tree data (point) is located /// /// The quadrant numbering: /// --------- /// | 0 | 1 | /// --------- /// | 2 | 3 | /// --------- /// </summary> /// <param name="in_point">Tree data (point) to check</param> /// <returns>Index of the quadrant [0..3]</returns> public int GetQuadrantIndex(IQuadTreeData in_point) { int quadrant = 0; if (in_point.X > CenterX) { quadrant += 1; } if (in_point.Y > CenterY) { quadrant += 2; } return(quadrant); }
/// <summary> /// Checks if the given quadtree data (point) is inside the region. /// </summary> /// <param name="in_point">Quadtree data containing the coordinates to check</param> /// <returns>True if point is inside the region</returns> public bool IsPointInside(IQuadTreeData in_point) { return((Math.Abs(CenterX - in_point.X) <= HalfSize) && (Math.Abs(CenterY - in_point.Y) <= HalfSize)); }