Computing a 3D quadrilateral inscribed sphere at its center?

80 Views Asked by At

For my game, I need to know when the player is over a powerup and for this I use a sphere collider:

3rd side view:

enter image description here

Legend:

  • orange, the powerup outline, a quad for which I know its centroid
  • green, sphere collider outline, its center is quad centroid but radius is random for now

Radius for circumscribed circle is easy since I know center and vertices it should encompass:

enter image description here

Radius for inscribed circle is what I'd like to achieve instead:

enter image description here

I guess I am close with the following links but unsure as on how to do it for 3D points:

https://en.wikipedia.org/wiki/Tangential_quadrilateral

https://en.wikipedia.org/wiki/Bicentric_quadrilateral

So, knowing a 3D quadrilateral and its centroid, how can I find the radius of an inscribed sphere at its center?

1

There are 1 best solutions below

1
On BEST ANSWER

(Comment, but not enough rep for commenting.)

For a square quadrilateral with inradius $r$ and outradius $R$, $R = r \sqrt{2}$.

For a generic quadrilateral, I would suggest half of some sort of mean (or minimum or maximum) of the two diagonals; for example, $$\begin{aligned} d_{sum} &= \sqrt{ (x_3 - x_1)^2 + (y_3 - y_1)^2 + (z_3 - z_1)^2 } \\ ~ &+ \sqrt{ (x_4 - x_2)^2 + (y_4 - y_2)^2 + (z_4 - z_2)^2 }\\ r &= \frac{d_{sum}}{4\sqrt{2}} \end{aligned}$$ Depending on the shapes, you could use half the root-mean-square of the diagonals divided by square root of two, $$r = \frac{1}{4}\sqrt{ (x_3 - x_1)^2 + (y_3 - y_1)^2 + (z_3 - z_1)^2 + (x_4 - x_2)^2 + (y_4 - y_2)^2 + (z_4 - z_2)^2 }$$