I am working on an interface to a computational solid geometry program. I would like this program to be able to fillet corners (although fillet sometimes seems to refer to an internally smoothed corner, while 'corner radius' is used for the effect I am interested in). Basically I want to round them off to a smoothed 3D curved surface like so:

For a cuboid, this effect can be achieved by a series of union and difference operations using a sphere of the desired fillet radius 'resting' in the corner of the cuboid. However, what I would like to know is,
1) can this be generalized to any polyhedron corner? i.e. resting a sphere in the corner of any polyhedron.
2) How can I implement it? i.e. is there a general method of finding the minimum distance of a sphere to the corner of any polyhedron (or similar for whatever the correct method of doing this is)?
Any method would only have to work for fairly 'normal' polyhedrons. Unusual edge cases which are not likely to be required in the physical world can be ignored.
The formula can be easily generalized for any regular polyhedron such as the vertex of platonic solid, the vertex of a right pyramid with regular polygonal base, vertex of regular bi-pyramid etc.
Let there be sphere, with a radius $\color{blue}{R}$, resting in a corner (i.e. vertex of a regular polyhedron) at which $\color{blue}{n}$ no. of the edges meet together such that the angle between any two consecutive edges is $\color{blue}{\alpha}$.
Assuming that the vertex is sufficiently large to accommodate the sphere in it such that sphere touches all the faces meeting at that vertex but does not touch any of the edges meeting at that vertex. Then we have
The minimum distance of the sphere from the vertex is given by the generalized formula derived in mathematical analysis of sphere snugly fitted in the vertex by HCR$$\bbox[4pt, border: 1px solid blue;]{\color{red}{d_{min}=\frac{R\left(\tan\frac{\pi}{n}-\tan\frac{\alpha}{2}\right)}{\tan\frac{\alpha}{2}}}}$$
Where, $\color{blue}{\text{n is a natural number}}$ $\implies \color{blue}{n\geq3}$ & $\color{blue}{\alpha<\frac{2\pi}{n}}$
Now, in order to make the corner (vertex) smooth, the corner should be truncated by a normal height (depth) equal to $\color{blue}{d_{min}}$ then each of $\color{blue}{n}$ no. of faces must be filleted through a radius $\color{blue}{R_{f}}$ given by the generalized formula $$\bbox[4pt, border: 1px solid blue;]{\color{red}{R_{f}=R\tan\frac{\pi}{n}\tan\left(\frac{\pi+\alpha}{4}\right)\sqrt{\frac{\sin\left(\frac{\pi}{n}-\frac{\alpha}{2}\right)}{\sin\left(\frac{\pi}{n}+\frac{\alpha}{2}\right)}}}}$$
The figure below shows a triangular face, with vertex angle $\alpha$, initially meeting at the vertex P is first truncated though the line $A_{1}J A_{2}$ then it is filleted through a radius $R_{f}$ with center at the point O lying at the bisector of angle $\alpha$. Thus all the faces meeting at the vertex are rounded/filleted to best fit the sphere.