Problem: Given two arbitrary rings in 3D space find the distance between them. Seemed like a simple problem at first, but I'm struggling to find a good way to approach it.
More specifically, what are the point(s) on each ring that are closest to the other, and the distance between those points. I'm looking for a simple analytical solution. I believe possible solution sets are limited to one of the following cases:
- every point on each ring, if they are coaxial
- exactly 2 points on each ring otherwise, and if one overlaps the other when projected onto its normal plane
- single point on each ring otherwise.
Thoughts so far: First thing I need is a notation for the two rings. I figured each could be defined by a center point, a normal vector and a radius for example. Doesn't matter what, since it should be easy enough to translate between different notations.
To find the minimum distance, I tried a brute force method: calculate distance between an arbitrary point on one ring to an arbitrary point on the other, then minimize that distance by setting the derivative to zero (and picking the solution corresponding to the minimum, not maximum).
I tried using the parameterization from this answer:
$$x(\theta) = c_1 + r\cos(\theta)a_1 + r\sin(\theta)b_1$$ $$y(\theta) = c_2 + r\cos(\theta)a_2 + r\sin(\theta)b_2$$ $$z(\theta) = c_3 + r\cos(\theta)a_3 + r\sin(\theta)b_3$$
for two rings defined by the set of points $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$ that are functions of $\theta_1$ and $\theta_2$ respectively. Take the norm or norm^2 of the difference between those two vectors and you get a general expression for distance. Take the derivative of that with respect to $\theta_1$ and $\theta_2$ and set each to 0, then solve for $\theta_{1,2}$. Unfortunately, I just got an unsolvable mess and feel like there must be a better way to approach this.