public void ComputeRadius(Node parentNode) { //bottom up algorithm. (From leaf to root) //With given leaf size, calculate parent hemsphere size and recursively compute upper level hemsphere size if (parentNode.nodeNumDecendents == 0) { parentNode.nodeHemsphereRadius = leafRadius; return; } else { float parentHemsphereArea = 0.0f; //Hp = sum of pi*r^2 foreach (Node child in parentNode.nodeChildren) { ComputeRadius(child); //recursive bottom up call //Euclidean Space Case for understnding: //parentHemsphereArea += Mathf.Pow(child.nodeHemsphereRadius, 2); //Hyperbolic Space Case: //H3Math.TWO_PI * (H3Math.cosh(r / K) - 1.0); //parentHemsphereArea += (float)(Math.PI * 2 * (Math.Cosh(child.nodeHemsphereRadius / 2) - 1)); parentHemsphereArea += (float)(Math.Cosh(child.nodeHemsphereRadius) - 1); } //Euclidean Space Case: //parentNode.nodeHemsphereRadius = Mathf.Sqrt(parentHemsphereArea); //Hyperbolic Space Case: //K * H3Math.asinh(Math.sqrt(area / (H3Math.TWO_PI * K * K))); //parentNode.nodeHemsphereRadius = (float)HyperbolicMath.ASinh(Math.Sqrt(parentHemsphereArea / (Math.PI * 2 * 4))) * 2; parentNode.nodeHemsphereRadius = (float)HyperbolicMath.ASinh(Math.Sqrt(parentHemsphereArea)); } return; }