<p>I have a mesh of a bowl that has the perfect shape of half a sphere. I want to easily convert it to the containing sphere solid and a box solid that will be subtracted from it.</p>

<p><a href="https://i.stack.imgur.com/FlT0X.png" rel="nofollow noreferrer" title="Conversion process"><img src="https://i.stack.imgur.com/FlT0X.png" alt="Conversion process" title="Conversion process"></a></p>

<p>Googling mesh to solid shows that in various tools such as 3ds Max, Fusion, etc., manual approximation of where the sphere might go is created manually by visually comparing to the mesh or the cross section when creating the solid but I am looking for the minimum enclosing sphere and box to be generated/calculated by the software.</p>

<p>Source file format is of course not an issue, it can be any known mesh file.</p>

The calculations for your objective could be considered simple geometry, although the results in terms of formulae are a bit more complex than simple, but not by much.
According to
Quora
, the foundation for this goal is that the cube's eight vertices will be coincidental to the sphere's surface. If one desires to print a 3D object with this form, such an object may fail the requirement of being manifold, but may not, depending on the floating point operations of the software being used.
I found a simplistic formula which provides the radius of the sphere given the length of the side of the cube.
```
```
$fn = 90;
edge = 10;
cube([edge, edge, edge], center = true);
sphere_radius = sqrt((3 * pow((edge/2), 2)));
sphere(sphere_radius);
```
```
The above code is done in
OpenSCAD
, resulting in this image with the sphere made transparent for clarity:
Translated into general English, it appears that one can take the edge length, divided by 2, then take the square of that result and triple it. Take the square root of that value and it becomes the radius of the sphere.
The above answer is courtesy of
Math Forum
and is represented verbatim as such:
```
```
____________________________
  D = \| (L/2)^2 + (L/2)^2 + (L/2)^2
```
```
The letter D in this case appears to be slightly misrepresented as diameter when it should be referred to as radius.
As part of this fun exercise, I also subtracted the cube from the sphere, slicing it in half for visibility, resulting in this image: