How to find the inverse arc in the configuration space The following Figure shows the function from configuration space (Torus) to operational space (Annulus).

There is a naturally defined continuous function from configuration space $(\theta_A, \theta_B)$ to operational space $f(\theta_A, \theta_B)$. If any of $\theta_A$ and $\theta_B$ varies, chalk at the end of rod B draws an 'arc',  
Supposing we have an arc in operational space and we want to find its inverse arc in configuration space. Here are two simple examples:

 
The problem is how can we find the arc of the configuration space (i.e. $\theta_A=f(\theta_B)$ for the following two operational space?:

All I have approached is a little knowledge:
$1-$ the coordinate $(x,y)$ of the end point can be determined through: 
$x={l_A}{\cos\theta_A}+{l_B}{\cos(\theta_A+\theta_B)}$ and $y={l_A}{\sin\theta_A}+{l_B}{\sin(\theta_A+\theta_B)}$.
$2-$ The polar equation of the left picture is $r^2−2{l_B}r\cos(\theta)+{l_B}^2={l_A}^2$. But $\theta$ is in operational space, nothing to say about $(\theta_A,\theta_B)$ in configuration space (?)
How it is possible to find the relation between $\theta_A$ and $\theta_B$ such that results in the mentioned arcs?
I don't have any clue how to solve it. I would highly appreciate any helps. Thank you.  
 A: I'll write $(x, y)$ or $(r, \theta)$ for the coordinates of the point in the operational space, respectively in cartesian or polar coordinates.
First important remark : the map $(\theta_A, \theta_B) \mapsto (x,y)$ shears and then flatten the torus onto the annulus. The shearing part is bijective, and the "flattening" is two-to-one, except on the boundary of the annulus where it is one-to-one. Hence, there will be in general two possible choices of $(\theta_A, \theta_B)$ for any given position of the chalk. If $(\theta_A, \theta_B)$ works, then by symmetry, so does $(2\theta-\theta_A, -\theta_B)$.
To make things a bit clearer, I'll write $a$, $b$ instead of $l_A$, $l_B$.
I - Finding $\theta_B$
By Al-Kashi's theorem (the law of cosine),
$$r^2 = a^2+b^2+2ab\cos(\theta_B).$$
Among the two possible set of parameters for a given position, there is always exactly one with $\theta_B \in [0, \pi]$. I choose to compute this position. Then:
$$\theta_B = \arccos \left( \frac{r^2-a^2-b^2}{2ab} \right),$$
and:
$$\sin(\theta_B) = \frac{\sqrt{(r-a+b)(r+a-b)(a+b-r)(a+b+r)}}{2ab}.$$
I think this formula can also be deduced from the law of sine and Heron's formula for the area. If you choose the other value of $\theta_B$, which lies in $[-\pi, 0]$, then $\sin(\theta_B)$ becomes the opposite of the value above.
II - Finding $\theta_A$
Now, let's develop the equations giving $x$ and $y$:
$$\begin{cases}
x & = & a \cos (\theta_A) + b \cos (\theta_A+\theta_B) \\
y & = & a \sin (\theta_A) + b \sin (\theta_A+\theta_B)
\end{cases}$$
becomes:
$$\begin{cases}
x & = & [a + b \cos (\theta_B)] \cos (\theta_A) - b \sin(\theta_B) \sin(\theta_A) \\
y & = &  b \sin (\theta_B) \cos (\theta_A) + [a + b \cos (\theta_B)] \sin (\theta_A)
\end{cases}$$
If we replace $\cos(\theta_B)$ by its expression we found at the beginning, we see that each column has norm $r$. So, by dividing by $r$, we get:
$$\begin{pmatrix}
\cos(\theta) \\ \sin(\theta)
\end{pmatrix}
= \begin{pmatrix}
\frac{a+b\cos(\theta_B)}{r} & -\frac{b \sin(\theta_B)}{r} \\
\frac{b \sin(\theta_B)}{r} & \frac{a+b\cos(\theta_B)}{r}  
\end{pmatrix}
\begin{pmatrix}
\cos(\theta_A) \\ \sin(\theta_A)
\end{pmatrix}$$
Since the 2x2 matrix is a rotation matrix, it is enough to transpose it to get its inverse, whence:
$$\begin{pmatrix}
\cos(\theta_A) \\ \sin(\theta_A)
\end{pmatrix}
= \begin{pmatrix}
\frac{a+b\cos(\theta_B)}{r} & \frac{b \sin(\theta_B)}{r} \\
-\frac{b \sin(\theta_B)}{r} & \frac{a+b\cos(\theta_B)}{r}  
\end{pmatrix}
\begin{pmatrix}
\cos(\theta) \\ \sin(\theta)
\end{pmatrix}.$$
From here, finding $\theta_A$ is just a matter of computing an angle from its sine and cosine.
III - Parametrization of the circle
If you have an arc in operational space and you want to compute a time-dependent parametrization $(\theta_A, \theta_B) (t)$ which follows the arc you want, all you have to do is to compute pointwise $\theta_B$ and $\theta_A$ with the recipe above. However, it can be quite tedious, especially for the special case where everything can be made explicit.
I won't deal with your arc $p_2$, as I don't have an equation for this curve. That said, let's have a look at $p_1$. It is a circle of radius $a$ and center $(b, 0)$. Since it makes a full turn around the origin, the parameter $\theta_A$ must also make a turn. I'll assume that one can do so monotonically, i.e. one can take $\theta_A (t)= t$. Let $f(t)$ be the value of $\theta_B$ at time $t$. Then:
$$\begin{cases}
x (t) & = & a \cos (t) + b \cos (t+f(t)) \\
y (t) & = & a \sin (t) + b \sin (t+f(t))
\end{cases}$$
But since $(x,y)$ belongs to the circle,
$$(x-b)^2+y^2=a^2$$
Replace $x$ and $y$ by the functions of $t$, develop, simplify a lot, and get:
$$b(1-\cos(f(t)+t)) + a(\cos(f(t))-\cos(t)) = 0,$$
which, with the help of some trigonometric formula, yields:
$$\sin \left(\frac{f(t)+t}{2} \right) \left[ b \sin \left(\frac{f(t)+t}{2} \right) - a \sin \left(\frac{f(t)-t}{2} \right) \right] = 0.$$
The equation above has one obvious solution: $f(t) = -t$. Hence, if you input $(\theta_A, \theta_B) (t) = (t, -t)$, you will draw the curve $p_1$. The second branch is more delicate to compute. By developping the sine, we get:
$$(a+b) \sin \left(\frac{t}{2} \right) \cos \left(\frac{f(t)}{2} \right)  = (a-b) \cos \left(\frac{t}{2} \right) \sin \left(\frac{f(t)}{2} \right),$$
whence:
$$\tan \left(\frac{f(t)}{2} \right)  = \frac{a+b}{a-b} \tan \left(\frac{t}{2} \right).$$
Finally, we get:
$$f(t) = 2 \arctan \left( \frac{a+b}{a-b} \tan \left(\frac{t}{2} \right) \right),$$
which is well-defined for $t \neq \pi$ (but that is not a problem, as $f(\pi) = \pi$ necessarily).
A: In complex numbers, your planimeter measures $f(\theta_A, \theta_B) = A e^{i \theta_A} + B e^{i(\theta_A + \theta_B)} $.  There doesn't seem to be any restriction on the angle so $0 \leq \theta_A, \theta_B < 2\pi$.  Maybe it will be easier to use $\theta_{B'} = \theta_A + \theta_B$ and the configuration space will still be the same torus "twisted".
Your image will be the Minkowski sum of the two circles of radius $A$ and $B$ and the result is that $f$ is a 2-1 map from the torus to an annulus.  except at the edges where it's 1-1.  It's like loooking at a donut with radii $A,B$ from the top.

How to compute $f^{-1}$ ?  
The $f(\theta_A + \delta , \theta_{B'} + \delta) = e^{i\delta}f(\theta_A , \theta_{B'} )  $.  This means rotating the annulus is the same as moving diagonally in the donut in the NE diagonal direction $(1,1)$.
The radius can be computed from the Law of cosines: $|f(\theta_A, \theta_B)| = A^2 + B^2 + 2AB \cos \theta_B $

A reasonable thing to do would be draw the torus in 3D and plug into the equation of your circle of interest.
$(\theta,\phi) \mapsto (  (A + B \sin \theta) \cos \phi, (A + B \sin \theta ) \sin \phi, B \cos \theta) $
