# Calculate angles from connected links and point coordinates

I have a problem. Earlier I posted a subproblem of this one but poorly asked so I hope I do better this time.

I have an example which is a more simple one of my actual problem:

I want to find two angles (theta_2 and theta_3) given two links with known link lengths(a2, a3) and a known end point (r,s).

With the law of cosines the two angles theta_2 and theta_3 can be found.

theta_3 = atan2(d, +-sqrt(1-d^2)) where

d = (r^2 + s^2 - a2^2 - a3^2) / (2*a2*a3)

theta_2 then becomes:

theta_2 = atan2(r,s) - atan2(a2+a3*cos(theta_3), a3*sin(theta_3))

And that is all understood. But now if I make the problem slightly more complicated I cannot figure out how to find these angles anymore.

Now consider this problem which is exactely the same as problem 1, just with a rigidly attached link at the end point in a 90 degree angle:

How can I now solve for the angles given only the three link lengths (a2, a3, d) and the coordinates of point D?

• Please provide a link to the "sub problem" you posted earlier. – amWhy Aug 3 '17 at 16:59
• I deleted that question. I removed the mention of that no to confuse people. – ruffy Aug 3 '17 at 17:02
• If there were a diagram of the configuration you intend, I might have spent time on this problem. – Eric Towers Aug 3 '17 at 17:12
• @ruffy once you earn a bit more in the way of reputation, you'll be able to insert images into your post, like I did above. – amWhy Aug 3 '17 at 17:29
• @ruffy Solve the problem for fixed point $D$ and lengths $\,a_2, \sqrt{a_3^2+d^2}\,$, then add $\,\arctan(d / a_3)\,$ to the second angle. – dxiv Aug 3 '17 at 17:42

The right triangle $\triangle CBD$ has fixed-size legs of lengths $a_3$ and $d$ respectively, so its hypotenuse will have fixed length $\sqrt{a_3^2+d^2}$ by Pythagoras' theorem.
Given the fixed point $D$ and the known distances $a_2$ and $\sqrt{a_3^2+d^2}\,$, the angles $\theta_2$ and $\theta_3^{\,'}$ can be determined as shown in the posted solution to the first problem, where $\theta_3^{\,'}$ is the angle between $BD$ and the dashed line marked with an arrow.
The last step is to note that $\theta_3 - \theta_3^{\,'} = \angle CBD=\arctan(d / a_3)\,$, so $\theta_3 = \theta_3^{\,'} + \arctan(d / a_3)\,$.
• @ruffy Once you solved the first case, all you have to do is substitute $\,(r,s) \mapsto (x_d,y_d)\,$ and $\,(a_2,a_3) \mapsto (a_2,\sqrt{a_3^2+d^2})\,$. – dxiv Aug 4 '17 at 17:36