# How to join two 3D lines with a third line that connects to each with tangent arcs?

I need help trying to find the equation of a 3rd line that connects two lines that are already defined in 3d space. The third line has to connect to the first two with "fillet"/tangent arcs, both of the same radius. See the picture for clarifications. I do NOT want the first two lines to change in any way. Their start and end points need to stay exactly where they are.

Knowns: Arc radius and all parameters of the two already defined lines...start and end points, start/end tangent.

• I can solve it in 2D, but the 3D version gives me headaches :) – Crouching Kitten Aug 9 '19 at 23:23
• At each junction, you have a 2-D problem. Just work in the plane defined by the pair of line segments, i.e., by their three endpoints. – amd Aug 10 '19 at 1:25
• Different comments. 1) A little precision about mathematical precise vocabulary : you work with line segments (not full lines which are infinite) 2) Your issue has in general no solution with circular arcs unless the line segments you want to connect are co-planar. 3) There are solutions using helical connecting arcs. – Jean Marie Aug 10 '19 at 17:48
• @amd I was also thinking of that, but I think that's not true for the endpoints, but only to their "extensions". Because the arcy head part would be out of the plane, so they wouldn't look at each other. – Crouching Kitten Aug 11 '19 at 10:16
• @JeanMarie: Concerning your 2): It may be that for too large $R$ there are no solutions of the given problem. But of course there may be circular solutions even if the two given carrying lines are nonplanar. – Christian Blatter Aug 11 '19 at 18:55

Let $$g_i$$ $$(1\leq i\leq 3)$$ be the lines on which the segments $$\ell_i$$ are lying, and denote by $$P_1$$, $$P_2$$ the given endpoints of $$\ell_1$$, $$\ell_2$$. The line $$g_1$$ and the unknown line $$g_3$$ are tangents to some circle (of given radius $$R$$). They therefore are lying in the plane $$\Pi_1$$ of this circle, hence intersect in a point $$Q_1\in g_1$$ outside of the segment $$\ell_1$$. The distance $$r_1:=|P_1Q_1|$$ is unknown; it depends on $$R$$ and the deflection angle $$\alpha_1$$ at $$Q_1$$ between $$g_1$$ and $$g_3$$. This $$\alpha_1$$ is the angle of the circular arc to be drawn later. It is easy to see that $$r_1=R\>\tan{\alpha_1\over2}\ .\tag{1}$$
In the same way we have between $$g_2$$ and $$g_3$$ the relation $$r_2=R\>\tan{\alpha_2\over2}\ .\tag{2}$$ But we have to be aware that each of the angles $$\alpha_i$$ depends on both $$r_i$$ in a complicated way, independent of these conditions.
Therefore you have to do the following: Consider the $$r_i$$ as variables ("unknowns"), and compute the points $$Q_i\in g_i$$ $$(1\leq i\leq2)$$. If $${\bf e}_i$$ is the unit vector giving the direction of $$g_i$$ then $${\bf q}_i={\bf p}_i+ r_i\>{\bf e_i}\qquad(1\leq i\leq 2)\ .$$ Since $$g_3=Q_1\vee Q_2$$ the direction vector of $$g_3$$ is $${\bf e}_3={{\bf q}_2-{\bf q}_1\over|{\bf q}_2-{\bf q}_1|}\ .$$ This $${\bf e}_3$$ will depend on $$r_1$$ and $$r_2$$. Compute the angles $$\alpha_1=\angle({\bf e}_1, {\bf e_3})$$, resp., $$\tan{\alpha_1\over2}$$, using vector algebra on the $${\bf e}_j$$. Similarly for $$\alpha_2$$. Then determine the $$r_i$$ from the equations $$(1)$$ and $$(2)$$. When these equations are satisfied you can properly fill in two circle arcs of radius $$R$$ beginning at $$P_1$$ and at $$P_2$$.
• Just for clarification: the relationship between $\alpha_i$ and $r_i$ that is independent from (1) and (2) comes from calculating the angle between the line on the extension points and $\ell_1$, $\ell_2$. – Crouching Kitten Aug 11 '19 at 11:21
• When I try to solve the problem with this method, I get a quite ugly system. The two line segments are between points $a_1$ and $a_2$, and for the other line between $b_1$ and $b_2$. The distances between the extension points and the ends of the segments are $d_a$ and $d_b$. The extension points are $e_a$ and $e_b$: $$\bar{e}_a=\bar{a}_2+d_a\frac{\bar{a}_2-\bar{a}_1}{\lVert \bar{a}_2-\bar{a}_1 \rVert}$$ $$\bar{e}_b=\bar{b}_2+d_b\frac{\bar{b}_2-\bar{b}_1}{\lVert \bar{b}_2-\bar{b}_1 \rVert}$$ The equations are in the next comment. – Crouching Kitten Aug 11 '19 at 17:50
• The only unknowns are $d_a$ and $d_b$, but it would take ages to solve it: $$\frac{\text{2}\!\:d_a^2}{r^2+d_a^2}-1=\frac{\left( \bar{e}_b-\bar{e}_a \right) \cdot \left( \bar{a}_1-\bar{a}_2 \right)}{\lVert \bar{e}_b-\bar{e}_a \rVert \!\:\lVert \bar{a}_1-\bar{a}_2 \rVert}$$ $$\frac{\text{2}\!\:d_b^2}{r^2+d_b^2}-1=\frac{\left( \bar{e}_a-\bar{e}_b \right) \cdot \left( \bar{b}_1-\bar{b}_2 \right)}{\lVert \bar{e}_a-\bar{e}_b \rVert \!\:\lVert \bar{b}_1-\bar{b}_2 \rVert}$$ – Crouching Kitten Aug 11 '19 at 17:50