@@ -104,6 +104,29 @@ extension type QuadTree$QueryResult._(Float32List _bytes) {
104104/// the QuadTree will not subdivide further and [capacity] will be ignored.
105105/// Suitable values for the depth are usually between 8 and 16.
106106/// Should be always greater or equal than 1.
107+ ///
108+ /// This formula computes the maximum depth of a quad tree based on the overall
109+ /// boundary size (`Boundary` ) and
110+ /// the desired minimal boundary size (`Size` ) for each node:
111+ ///
112+ /// maxDepth = ceil(log2(Boundary / Size))
113+ ///
114+ /// Where:
115+ /// - Boundary is the length of the entire boundary (e.g., the width or height
116+ /// of the area, assuming a square).
117+ /// - Size is the desired minimal boundary size for a node.
118+ /// - log2(...) is the logarithm base 2.
119+ /// - ceil(...) means rounding up to the next integer.
120+ ///
121+ /// For example, if the boundary is 1024x1024 and the desired minimal size is
122+ /// 64x64, the maximum depth of the quad tree will be:
123+ /// maxDepth = ceil(log2(1024 / 64)) = ceil(log2(16)) = ceil(4) = 4
124+ ///
125+ /// The quad tree subdivides its space by splitting each node
126+ /// into four quadrants, effectively halving the boundary at every level.
127+ /// Once the boundary size reaches the desired minimal size,
128+ /// the maximum depth is reached.
129+ ///
107130/// {@endtemplate}
108131final class QuadTree {
109132 /// Creates a new Quadtree with [boundary] and a [capacity] .
0 commit comments