Given two points on the surface of a sphere $\vec a$ and $\vec b$ and directions tangent to the sphere at those points, $\vec {a'}$ and $\vec {b'}$ how can I connect them with a pair of circular arcs that
- lie in the sphere $x^2 + y^2 + z^2 = 1$
- pass through respectively $\vec a$ and $\vec b$
- are tangent to $\vec {a'}$ at $\vec a$ and to $\vec {b'}$ at $\vec b$
- are tangent to each other
There is a family of solutions over which the ratio of the size of the arcs changes. At the extremes the points $\vec a$ and $\vec b$ are connected by a single arc that passes through $\vec a$ and $\vec b$ and is tangent to one of $\vec {a'}$ or $\vec {b'}$ (and you could imagine another arc at the other point of radius $0$).
I have previously solved this problem on a plane, and the points of intersections of the solutions lie on the circle that passes through both points and is tangent to the two extreme solutions.
Let
- $\vec v$ be a point on the sphere
- $\vec {c_a}$ be the center of a circle on the sphere passing through $\vec v$, $\vec a$, and tangent to $\vec {a'}$ at $\vec a$
- $\vec {c_b}$ be the center of a circle on the sphere passing through $\vec v$, $\vec b$, and tangent to $\vec {b'}$ at $\vec b$
Then
$$ \lVert \vec v \rVert = 1 $$
$\vec v$ and $\vec a$ are on the same circle around $\vec {c_a}$, and likewise for $\vec b$.
$$ \vec v \cdot \vec {c_a} = \vec a \cdot \vec {c_a} $$ $$ \vec v \cdot \vec {c_b} = \vec b \cdot \vec {c_b} $$
The circles are tangent to each other. I'm sure there's a way of saying this without resorting to the $\mathbb R^3$ specific cross product just to construct a basis.
$$ (\vec v - \vec c_a) \times \vec c_a = s*(\vec v - \vec c_b) \times \vec c_b $$
Things I know:
A circle:
- passing through a point $\vec v$
- passing through $\vec b$, and
- tangent to $\vec {b'}$ at $\vec b$
lies in the plane containing $\vec v$, $\vec b$, and $\vec b + \vec {b'}$. Such a circle is on the sphere if both points are on the sphere and the tangent is tangent to the sphere.
The center of a circle on the sphere passing through $\vec a$ tangent to $\vec {a'}$ is located on the plane passing through $\vec a$ and perpendicular to $\vec {a'}$.
$$ \vec {c_a} \cdot \vec {a'} = 0 $$ $$ \vec {c_b} \cdot \vec {b'} = 0 $$
The center of a circle on the sphere passing through $\vec a$ tangent to $\vec {a'}$ is located on the circle halfway between $\vec a$ and the circle around the sphere perpendicular to $\vec {a'}$ at $\vec {a}$.
Single solution
If you choose the circle at one end, you can construct a pair of circles that are tangent to it and the other end.
Let $\vec c_a$ be the center of a circle $C_a$ tangent to $\vec {a'}$ at $\vec a$.
Project $\vec b$ along $\vec {b'}$ onto the plane of the circle $C_a$, which we'll call $\vec b_{img}$.
Find lines tangent to the circle and passing through the projected point $\vec b_{img}$. The points of tangency $\vec v_1$ and $\vec v_2$ are the points were the circle $C_a$ intersect a pair of circles $C_{b1}$ and $C_{b2}$ respectively that are both in the sphere and tangent to $\vec {b'}$ at $\vec b$.
The circles $C_{b1}$ and $C_{b2}$ are the intersections with the sphere of a plane passing through $\vec b$, $\vec b_{img}$ and one of $\vec v_1$ or $\vec v_2$.
Only one of the two solutions is correct and connects $\vec a$ and $\vec b$ in the directions of $\vec {a'}$ and $\vec {b'}$, rather than in the opposite direction at one end.
The whole family?
The intersection points of the family of solutions appear to lie on two circles around the sphere.
Something about ellipsoids
For a solution with intersection point $\vec v$, the directions
$$ (\vec v - \vec a) \times \vec {a'} $$ $$ (\vec v - \vec b) \times \vec {b'} $$
are perpendicular to the planes the circles $C_a$ and $C_b$ lie in. Therefore the direction
$$ ((\vec v - \vec a) \times \vec {a'}) \times ((\vec v - \vec b) \times \vec {b'}) $$
is perpendicular to both of those planes, and is the direction a tangent to two circles in those two planes must be in. For them to be tangent at $\vec v$ they must be perpendicular to $\vec v$
$$ (((\vec v - \vec a) \times \vec {a'}) \times ((\vec v - \vec b) \times \vec {b'})) \cdot \vec v = 0 $$
If we expand this out as far as possible
$$ ((\vec v \times \vec {a'} - \vec a \times \vec {a'}) \times (\vec v \times \vec {b'} - \vec b \times \vec {b'}) ) \cdot \vec v = 0 $$
$$ ((\vec v \times \vec {a'} - \vec a \times \vec {a'}) \times (\vec v \times \vec {b'}) - ((\vec v \times \vec {a'} - \vec a \times \vec {a'}) \times (\vec b \times \vec {b'}) ) \cdot \vec v = 0 $$
$$ ( (\vec v \times \vec {a'}) \times (\vec v \times \vec {b'}) - (\vec a \times \vec {a'}) \times (\vec v \times \vec {b'}) - (\vec v \times \vec {a'}) \times (\vec b \times \vec {b'}) + (\vec a \times \vec {a'}) \times (\vec b \times \vec {b'}) ) \cdot \vec v = 0 $$
Cubic Term
First we deal with the seemingly cubic term $((\vec v \times \vec {a'}) \times (\vec v \times \vec {b'})) \cdot \vec v$ with the vector triple product $\vec u \times (\vec v \times \vec w) = (\vec u \cdot \vec w) \vec v - (\vec u \cdot \vec v) \vec w$
$$ ( ((\vec v \times \vec {a'}) \cdot \vec {b'}) \vec v - ((\vec v \times \vec {a'}) \cdot \vec v) \vec {b'} ) \cdot v $$
We observe that $(\vec v \times \vec {a'}) \cdot \vec v = 0$
$$ ((\vec v \times \vec {a'}) \cdot \vec {b'}) \vec v \cdot \vec v $$
and $\vec v \cdot \vec v = 1$. This seemingly cubic term is only linear:
$$ (\vec {a'} \times \vec {b'}) \cdot \vec v $$
Quadratic Terms
Next we deal with the quadratic terms
$$ - ((\vec a \times \vec {a'}) \times (\vec v \times \vec {b'})) \cdot \vec v $$ $$ + ((\vec b \times \vec {b'}) \times (\vec v \times \vec {a'})) \cdot \vec v $$
Which become $$ - (((\vec a \times \vec {a'}) \cdot \vec {b'}) \vec v - ((\vec a \times \vec {a'}) \cdot \vec v) \vec {b'}) ) \cdot \vec v $$ $$ + ((\vec b \times \vec {b'}) \cdot \vec {a'}) \vec v - ((\vec b \times \vec {b'}) \cdot \vec v) \vec {a'}) ) \cdot \vec v $$
The first half of each term is a constant, again because $\vec v \cdot \vec v = 1$. I think the second half of each term can be rearranged to be of the form ${\vec v}^T M \vec v$ where $M$ is an outer product.
$$ {\vec v}^T \left[ (\vec a \times \vec {a'}) {\vec {b'}}^T \right] \vec v $$ $$ {\vec v}^T \left[ (\vec b \times \vec {b'}) {\vec {a'}}^T \right] \vec v $$
I hoped to be able to read something out of this equation
$$ {\vec v}^T \left[ (\vec a \times \vec {a'}) {\vec {b'}}^T + (\vec b \times \vec {b'}) {\vec {a'}}^T \right] \vec v + (\vec {a'} \times \vec {b'} + (\vec a \times \vec {a'}) \times (\vec b \times \vec {b'}) ) \cdot \vec v - (\vec a \times \vec {a'}) + (\vec b \times \vec {b'}) = 0 $$










We are given a sphere that has a radius $R$ which can be assumed to be centered at the origin $(0,0,0)$. In addition, we're supplied with two points (vectors) $a$ and $b$ that lie on the surface of the sphere. Finally we're given two vectors $a'$ and $b'$ such that $ a' \cdot a = b' \cdot b = 0 $.
We want to generate exactly two circular arcs on the surface of the sphere, the first coming out of point $a$ along the direction $a'$, and joining the second arc smoothly at a point $J$, and smoothly means the two arcs have the same tangent direction at the meeting point $J$. Finally, the second arc extends from $J$ to point $b$ such that its tangent is along $b'$.
There are infinite such arcs. They can be parameterized by the angle $\theta$ that $-$ the normal vector to the plane of the first arc $-$ makes with two standard vectors which depend only on $a$ and $a'$.
The plane of the first arc contains the vector $a'$. Therefore, the normal to the plane of the first arc can expressed as
$ n_1 = \cos \theta u_1 + \sin \theta u_2 $
Where both $u_1$ and $u_2$ are perpendicular to $a'$ and to each other. So we can take
$ u_1 = \dfrac{a}{R} $ (Remember $R$ is the radius of the sphere).
and then, we take
$ u_2 = \dfrac{a' \times u_1}{\| a' \times u_1 \| } $
Now with $u_1, u_2$ and $\theta$ we have the plane of the first arc.
The equation of this plane is $n_1^T ( p - a ) = 0 $. And we know that the center of the arc is along the normal vector $n_1$, i.e. $C_1 = t n_1$. Substituting this, we get
$ C_1 = (n_1^T a) n_1 $
Now define the radial vector $w_1 = a - C_1 $ and $ w_2 = n_1 \times w_1 $, then, the parametric equation of the first arc is
$ p_1(t_1) = C_1 + \cos(t_1) w_1 + \sin(t_1) w_2 $
The tangent vector to $p_1$ at $t_1$ is given by
$ p'_1 (t_1) = - \sin(t_1) w_1 + \cos(t_1) w_2 $
Now to get the second arc, we have to get the normal vector to its plane $n_2$. Naturally, we have
$ n_2 = b' \times (p_1 - b) \hspace{10pt}(1) $
And in addition, we have to impose that
$ n_2 \cdot p'_1 = 0 \hspace{10pt}(2) $
Expanding the first of these two equations, we get
$ n_2 = b' \times ( C_1 - b + w_1 \cos(t_1) + w_2 \sin(t_1) ) $
Which can be written compactly as
$ n_2 = v_0 + v_1 \cos(t_1) + v_2 \sin(t_1) $
where $v_0 = b' \times (C_1 - b) , v_1 = b' \times w_1 , v_2 = b' \times w_2 $
Plugging this into $(2)$, we get
$ (v_0 + v_1 \cos(t_1) + v_2 \sin(t_1) ) \cdot ( - sin(t_1) w_1 + \cos(t_1) w_2 ) = 0 $
Expanding this trigonometric equation gives us an equation of the form
$ A \cos(t_1) + B \sin(t_1) + C \cos(2 t_1) + D \sin(2 t_1) + E = 0 $
where
$ A = v_0 \cdot w_2 $
$ B = - v_0 \cdot w_1 $
$ C = \dfrac{1}{2} ( v_1 \cdot w_2 + v_2 \cdot w_1 ) $
$ D = \dfrac{1}{2} ( v_2 \cdot w_2 - v_1 \cdot w_1 ) $
$ E = \dfrac{1}{2} ( v_1 \cdot w_2 - v_2 \cdot w_1 ) $
This equation can be solved exactly, because it amounts to solving a quartic (degree 4) polynomial equation, and this can be done in closed form.
There will be two solutions associated with the above equation.
Now we have the joining point $J$ given by
$ J = C_1 + w_1 \cos(t_1) + w_2 \sin(t_1) $
The normal vector to the plane of the second arc is given by (see above)
$ n_2 = v_0 + v_1 \cos(t_1) + v_2 \sin(t_1) $
After normalizing $n_2$, we calculate the center of the second arc
$ C_2 = (n_2^T b) n_2 $
And we define the radial vector
$ z_1 = b - C_2 $
and
$ z_2 = n_2 \times z_1 $
Then the second arc will be
$ p_2 (t) = C_2 + \cos(t) z_1 + \sin(t) z_2 $
From the coordinates of $J$ we can get the parameter $t_2$ such that $p_2(t_2) = J $.
What is left is to plot the two arcs.
In my implementation, I've ignored the sense of $b'$ and generated arcs that end at $b$ along $b'$ and $-b'$. In the following examples, the red dot is point $a$ and the blue dot is point $b$. The green dot is point $J$ the joining point. Here is the first example:
And a second example:
And a third example:
