Furthest distance between two circles in 3D I have two circles in 3D specified by their centers, $c_1, c_2$, their radii, $r_1, r_2$, and the normals of the plane each circle is embedded in, $n_1, n_2$. Note that $n_1$ is not necessarily parallel to $n_2$. 
I wish to find the points $p_1$ on the first circle and $p_2$ on the second such that $|p_1p_2|$ is maximized. 
How do I do this?
 A: Define the equations for each circle parametrically, $f_1(t_1) = (a(t_1), b(t_1), c(t_1))$, and similarly for $f_2(t_2)$.  It's important to use to different independent variables. 
Use $f_1$ and $f_2$ to define a distance function between the two circles at time $t_1, t_2$.  Find where the derivative of this distance function with respect to $t_1$ is zero.  This will give you a set of critical points for any particular $t_2$. 
Now take this function and take the derivative with respect to $t_2$ and find where this is zero.  
This will give you points that are critical for both $t_1$ and $t_2$ (these derivatives can technically be taken in the opposite order, as well). 
This will give you maximum and minimum points, and possibly some other critical points such as inflection points.  You'll have to test this set of points to see which is which. 
The solutions will be periodic, so you can restrict your attention to those points between $[0, 2\pi]$, or whatever one period is depending on your parameterization. 
A: Let's see if this helps. Let $\mathbf{x}_1 = (x_1,y_1,z_1)$ and $\mathbf{x}_2 = (x_2,y_2,z_2)$ be two points lying on the circles 1 and 2, respectively. Then, the parametric equations for these points are given by (see here for a derivation):
\begin{align}
\mathbf{x}_1 & = \mathbf{c}_1 + r_1 (\cos \theta \,  \mathbf{a} + \sin \theta  \,\mathbf{b}),\\
\mathbf{x}_2 & = \mathbf{c}_2 + r_2 (\cos \lambda \,  \mathbf{p} + \sin \lambda  \,\mathbf{q}),
\end{align} for $\theta, \lambda \in [0,2\pi)$. The way to compute the unit vectors $\mathbf{a}$ and $\mathbf{b}$ and  $\mathbf{p}$ and $\mathbf{q}$ from $\mathbf{n}_1$ and $\mathbf{n}_2$ is explained in the link above. Now, the distance between points pertaining to each circle is given by:
$$ d(\mathbf{x}_1,\mathbf{x}_2) = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2 + (z_1 - z_2)^2}, $$  which depends exclusively on $\theta$ and $\lambda$. This will become your function to maximize, or more conveniently $d^2$. The set of critical points is then given by the equation: 
$$ \partial_\theta d^2 = 0, \quad \partial_\lambda  d^2 = 0,$$ i.e., the gradient of $d^2$, with respect to the independent variables, $\theta$ and $\lambda$, must be zero (necessary condition for optimality). 
Edit. This is definitely wrong: I don't know if setting $\lambda = \theta$, in order to make $d$ only dependent on one variable, makes any sense, since there's no restriction for doing that (I strongly think that this is not legit). 
Hope this helps.
Cheers.
