# How do you find the two arcs to make a path between two points and two tangents?

Say I have two points $$A$$ and $$B$$ in an $$(x,y)$$ plane and tangents of the points which are normalised vectors $$\mathrm{dir} A$$ $$\mathrm{dir} B$$, how do you find a path made of two arcs that join them together?

Here is a visual of what I mean. Since the images are not clear, the grey vectors from the two tangents are equal in magnitude but the magnitude is unknown.

Note: I am looking for perfect arcs not cubic bezier curves.

• assuming the directions are normalized, in order to find the segments that act as guides you need to solve $|(A+a \times dirA)-(B-b \times dirB)|=a+b$, where a is the length of the segment that starts from A and b is the length of the segments that ends in B (there could be two solutions, but if the initial directions are oriented along the path like you show in the picture you should exclude the negative solution) Apr 13 '20 at 8:01

Geogebra drawing

Say that you have a line $$a$$ defined by two points, $$A$$ and $$A'$$, and a line $$b$$ defined by points $$B$$ and $$B'$$. In my Geogebra drawing you can adjust directions of lines $$a,b$$ by moving points $$A'$$ and $$B'$$. You want to create a smooth curve APB made of two circular arcs, $$AP$$ and $$PB$$, so that arc $$AP$$ is tangent to line $$a$$ at point $$A$$ and arc $$PB$$ is tangent to line $$b$$ at point $$B$$.

First of all, if nothing else is given, there are infinitely many solutions. I will show that exactly one solution can be obtianed by fixing point $$D$$ on line $$a$$ so that line $$DPE$$ is tangent to both arcs at point $$P$$.

Introduce $$F=a\cap b$$. I will discuss only one case

• when point $$F$$ exists ($$a \not\parallel b$$)
• point $$D$$ is between $$F$$ and $$A$$
• point $$E$$ is between $$F$$ and $$B$$

Other cases can be discussed in a similar way.

The followin lengths and angle are known:

$$p=FA, q=FB, x=FD, \alpha=\angle AFB$$

The only problem is to calculate $$y=FE$$. Note that:

$$DE=DP+EP=DA+EB=(FA-FD)+(FB-FE)=p-x+q-y$$

On the other side:

$$DE^2=FD^2+FE^2-2FD\cdot FE \cos\angle AFB\tag{1}$$

or:

$$(p-x+q-y)^2=x^2+y^2-2xy\cos\alpha$$

$$p^2+q^2-2px+2pq-2py-2xq+2xy-2qy=-2xy\cos\alpha$$

$$p^2+q^2-2px+2pq-2xq=2py-2xy+2qy-2xy\cos\alpha$$

$$(p+q)^2-2x(p+q)=2y(p+q-x(1+\cos\alpha))$$

$$FE=y=\frac{p+q}{2}\ \frac{p+q-2x}{p+q-x(1+\cos\alpha)}$$

Now that you have point $$E$$, finding point P is easy (because $$DP=DA,EP=EB$$).

Center of arc AP can be found by intersecting line perpendicular to $$DP$$ at $$P$$ and bisector of angle $$PDA$$. In a similar way you can find the center of arc $$BP$$ (construction not shown).

You can play with my Geogebra drawing by moving lines $$a$$ and $$b$$ and adjusting position of point $$D$$. Basically, you can play with blue dots.

Other cases, for example, when $$A$$ is between $$F$$ and $$D$$ are also interesting. I'll leave detailed analysis up to you:

EDIT:

In the meantime WDUK added another condition:

$$AD=DP=PE=BE=z$$

In this case, by applying cosine theorem (1) to triangle $$FDE$$ we get the following equation:

$$(p-z)^2+(q-z)^2-2(p-z)(q-z)\cos\alpha=(2z)^2$$

The solutions are:

$$z_1=\frac{-p-q+(p+q)\cos\alpha+\sqrt{3p^2+2pq+3q^2-8pq\cos\alpha+(p-q)^2\cos^2\alpha}}{2(1+\cos\alpha)}$$

$$z_2=-\frac{p+q-(p+q)\cos\alpha+\sqrt{3p^2+2pq+3q^2-8pq\cos\alpha+(p-q)^2\cos^2\alpha}}{2(1+\cos\alpha)}$$

...and therefore we have two possible solutions, $$APB$$ and $$AQB$$:

Geogebra

EDIT 2:

Another example:

$$FA=p,\ FB=q,\ AD=DP=PE=BE=z$$

In this case, by applying cosine theorem (1) to triangle $$FDE$$ we get the following equation:

$$(p+z)^2+(q-z)^2-2(p+z)(q-z)\cos\alpha=(2z)^2$$

The positive solution of this quadratic equation is:

$$z=\frac{-p+q+(-p+q)\cos\alpha-\sqrt{3p^2-2pq+3q^2-8pq\cos\alpha+(p+q)^2\cos^2\alpha}}{2(-1+\cos\alpha)}$$

This defines positions of points $$D$$ and $$E$$. The rest of the construction is trivial.

• You mention the following lengths are known x = FD but you never showed how to calculate the position of D. Since from what i gather you find D from knowing where P is tangent to the two arcs, but we don't know the two arcs yet either. I should mention (don't know if this simplifies the math) but from my original image, AD and BE are to be assumed equal in magnitude which gives a constraint to guarantee only one solution.
– WDUK
Apr 16 '20 at 19:42
• @WDUK You are changing the description of the problem a LOT! You should have mentioned that DP should be equal to PE. I had to limit the number of solutions somehow and I did that by choosing point D arbitrarily. You are talking about a completely different problem now. Apr 16 '20 at 19:57
• I thought the images made it clear the grey vectors from the tangents were equal in magnitude. Which was why they were drawn in. Maybe i should've made it more clear in the images.
– WDUK
Apr 16 '20 at 20:11
• @WDUK It just looks so. If it's not mentioned, it cannot be guessed. I'll try to provide a new answer. Apr 16 '20 at 20:12
• I've noticed, all your tangents are counter pointing to each other. So they don't form one continuous path from A to B (or B to A). Instead they point in a direction that would lead to a meeting point at the middle of the two arcs (P or Q). For example your tangents match the top right example in my question but your solution does not follow the directions, its only finding arcs that match tangents. You can't reach B via AQB since the tangent points the wrong way (you would be going the wrong way around blue arc). You can't reach B from P since A's direction is the other way. Make sense?
– WDUK
Apr 16 '20 at 21:35