There are plenty of online articles for the 2D case. A simple google search will show that this link provides a good explanation about how this is done in 2D. It also shows how to construct the circle center geometrically. So, what you need to do is
1) Find a plane from the 3 points and create a 2D coordinate system on that plane.
2) Convert all 3 points to that 2D coordinate system.
3) Find the circle center using the link above.
4) Convert the circle center (in 2D) back to 3D.
Edit 1: I added the steps for creating a local coordinate system (CS) on a plane defined by 3 points
1) Compute unit vector n1 from P1 and P2. Use this as the x-axis for the local CS.
2) Compute unit vector n2 from P1 and P3.
3) Use n1 x n2 (where 'x' means the cross product) as the z-axis of the local CS.
4) Use (n1 x n2) x n1 as the y-axis of the local CS.
5) Now, you have a local coordinate system, I hope that you know how to convert P1, P2 and P3 to this local CS. After the conversion, the new coordinates for these 3 points should all have their z values = 0.0. You can then use their (x, y) values to find the center of the circle.
If you have all 3 points collinear, you cannot create a local CS and you cannot find a circle from 3 collinear points either.
Here's a completely different approach that might be easier to encode.
Your two given points ($(x_1, y_1)$ and $(x_2, y_2)$) and the
centers of the two desired circles are at the four vertices of a
rhombus with side length $r$.
You can use the Pythagorean Theorem to find the length of the diagonal
of the rhombus from $(x_1, y_1)$ to $(x_2, y_2)$.
Better still, divide by two so you now have half the length of the diagonal.
The two diagonals of a rhombus are perpendicular,
so the point $(x_1, y_1)$, the center of the rhombus, and one of the
circles' centers make a right triangle with hypotenuse $r$
and one leg equal to half the known diagonal.
Use the Pythagorean Theorem to find half the length of the other diagonal.
Now you just need to construct line segments of that length with one
end at the center of the rhombus, perpendicular to the known diagonal,
and the other end of each segment will be the center of one of the
desired circles.
That's the entire rationale of the procedure.
For the detailed calculations, I'll assign names to various lengths as
we go along in order to keep the equations from getting too ugly.
(You'd probably want to do this anyway when you do this in software.)
Let $x_a = \frac12(x_2 - x_1)$ and $y_a = \frac12(y_2 - y_1)$;
then the center of the rhombus is at $(x_0,y_0) = (x_1+x_a, y_1+y_a)$
and half the length of the known diagonal is
$a = \sqrt{x_a^2 + y_a^2}.$
The length of the other diagonal is
$b = \sqrt{r^2 - a^2}.$
Now suppose (for example) that $(x_0,y_0)$ is above and to the right
of $(x_1,y_1)$ (assuming, at least for now,
the usual mathematical Cartesian $x,y$ coordinates).
To get from $(x_1,y_1)$ to $(x_0,y_0)$ along a straight line,
we go to the right $x_a$ units and up $y_a$ units for every
$a$ units of movement.
So to get from $(x_0,y_0)$ to the center of one of the circles,
$(x_3,y_3)$, we can just turn those rules $90$ degrees:
we can go down $x_a$ units and to the right $y_a$ units for every
$a$ units of movement;
that is, $\frac{x_a}{a}$ down and $\frac{y_a}{a}$ right for each unit
traveled along the diagonal.
But the distance from $(x_0,y_0)$ to $(x_3,y_3)$ is $b$,
so we will end up going down $b\frac{x_a}{a}$ units
and to the right $b\frac{y_a}{a}$ units.
In other words,
\begin{align}
x_3 &= x_0 + \frac{b y_a}{a}, \\
y_3 &= y_0 - \frac{b x_a}{a}. \\
\end{align}
To get to the center of the other circle, $(x_4,y_4)$,
we just go the same amount in the opposite direction from $(x_0,y_0)$:
\begin{align}
x_4 &= x_0 - \frac{b y_a}{a}, \\
y_4 &= y_0 + \frac{b x_a}{a}. \\
\end{align}
If $(x_0,y_0)$ is not above and to the right of $(x_1,y_1)$,
or if you're working in a graphics coordinate system with $y$ downward,
or both, the signs of either $x_a$ or $y_a$ (or both)
might be negative instead of positive; but all the formulas above
continue to work exactly the same way as before.
Best Answer
Your algorithm is very simple because it doesn't always work.
Suppose we are given the points $(1,0)$, $(2,0)$, and $(6,0)$. Your algorithm will first average them to get the point $(3,0)$, then compute a maximum distance of $3$. However, a better solution is to take a circle with center $(3.5,0)$ and radius $2.5$.