getAreaRatio method

double getAreaRatio()
override

Get the ratio of the sum of the node areas to the root area.

Implementation

double getAreaRatio() {
  if (_root == null) {
    return 0.0;
  }

  final DynamicTreeNode root = _root;
  double rootArea = root.aabb.getPerimeter();

  double totalArea = 0.0;
  for (int i = 0; i < _nodeCapacity; ++i) {
    final DynamicTreeNode node = _nodes[i];
    if (node.height < 0) {
      // Free node in pool
      continue;
    }

    totalArea += node.aabb.getPerimeter();
  }

  return totalArea / rootArea;
}