how to find center/radius of a sphere Say you have an irregular tetrahedron, but you know the (x,y,z) coordinates of the four vertices; is there a simple formula for finding a sphere whose center exists within the tetrahedron formed by the four points and on whose surface the four points lie?
 A: Simple formula, maybe not. 
Take any three out of four points. The sphere in question must contain the circle through the three points within the plane of the three points. Which is to say, take three points, circumscribe a circle around that triangle. That circle has a center. If you draw a line through that center, orthogonal to that plane, the center of the sphere is somewhere along that line. 
Now take out one of the points and put in the fourth, you now have a different three points in a different plane. Do the same things. The two  lines must intersect in the center of the sphere.
If any three of the points are nearly collinear, or the four are nearly coplanar, there are any number of ways to make the method more robust
A: The other answers reduce to the two-dimensional problem.
Why not reduce it to the one-dimensional problem:  The circumcentre is equidistant from each point.
Take the plane that is equidistant from $a$ and $b$, which is $2x\cdot(a-b)=|a|^2-|b|^2$.
There are six of these planes, take any three that involve all four points, and solve three equations in the three components of $x$
A: Given four points, a, b, c, and d, you can find the center by setting the following determinant to zero and solving it:
$$
\begin{vmatrix}
(x^2  + y^2  + z^2)  &  x &  y & z  & 1 \\
(ax^2 + ay^2 + az^2) & ax & ay & az & 1 \\
(bx^2 + by^2 + bz^2) & bx & by & bz & 1 \\
(cx^2 + cy^2 + cz^2) & cx & cy & cz & 1 \\
(dx^2 + dy^2 + dz^2) & dx & dy & dz & 1 \\
\end{vmatrix}
= 0
$$
The math is gnarly, but the following C++ code implements the solution:
class Point {
  public:
    double x;
    double y;
    double z;
    Point() { x = 0; y = 0; z = 0; }
    Point(double x_, double y_, double z_) { x = x_; y = y_; z = z_; }
};
    
class Sphere {
  public:
    Point center;
    double radius;
    Sphere(Point center_, double radius_) {
        center = Point(center_.x, center_.y, center_.z);
        radius = radius_;
    }
};
    
Sphere
sphereFromFourPoints(Point a, Point b, Point c, Point d)
{
#define U(a,b,c,d,e,f,g,h) (a.z - b.z)*(c.x*d.y - d.x*c.y) - (e.z - f.z)*(g.x*h.y - h.x*g.y)
#define D(x,y,a,b,c) (a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y))
#define E(x,y) ((ra*D(x,y,b,c,d) - rb*D(x,y,c,d,a) + rc*D(x,y,d,a,b) - rd*D(x,y,a,b,c)) / uvw)
    double u = U(a,b,c,d,b,c,d,a);
    double v = U(c,d,a,b,d,a,b,c);
    double w = U(a,c,d,b,b,d,a,c);
    double uvw = 2 * (u + v + w);
    if (uvw == 0.0) {
        // Oops.  The points are coplanar.
    }
    auto sq = [] (Point p) { return p.x*p.x + p.y*p.y + p.z*p.z; };
    double ra = sq(a);
    double rb = sq(b);
    double rc = sq(c);
    double rd = sq(d);
    double x0 = E(y,z);
    double y0 = E(z,x);
    double z0 = E(x,y);
    double radius = sqrt(sq(Point(a.x - x0, a.y - y0, a.z - z0)));
    return Sphere(Point(x0, y0, z0), radius);
}

A: The formula of a sphere is of the form : $$(x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 = R^2$$
Where $(x_0,y_0,z_0)$ is the centre of the sphere and $R$ is the radius.
If you know the four points of your tetrahedron, they must all satisfy the above equation so solving the system of four (second degree) equations with four unknowns ($x_0, y_0, z_0$ and $R$) is the way to go and gives you the centre of the sphere as well as the radius.
Beware, the above equations can give you more than one solution as they are second order.
There might be a magic formula where you just plug it in but I think it is very ugly assuming it exists. Best way would be to solve the system.
A: Hint:
Step 1:  Find circumcircle $A$ for any three of the four points.
Step 2:  Find a circumcircle for the fourth point $P$ together with two points connected by a diameter $l$ of circle $A$ where a plane containing $l$ meets $A$ at a perpendicular angle and also contains $P$.
Then your circumsphere has radius and center equivalent to the radius and center of the circle found in step 2.
