2
$\begingroup$

I've been trying to study concepts from the field of inverse-kinematics, but have run into a mathematical roadblock.

To solve for an angle given a number is quite simple in itself

$$ \sin(\theta) = x $$ $$ \arcsin(x) = \theta $$ The problem I am having is for "additive function equations" like sin or log that require their inverse to solve for the inner variable:

\begin{cases} \frac X{1.5}=\cos(\theta_1)+\cos(\theta_1+\theta_2) \\ \frac Y{1.5}=\sin(\theta_1)+\sin(\theta_1+\theta_2)\end{cases} Where I would want to solve the equation for arbitrary $\theta_1$ and $\theta_2$.

Because of my programming experience, my "brute-force" solution would be to create a table of all possible combinations of thetas and their respective $x$ and $y$ values given that $\theta$ can range from $0$ to $2\pi$. But I really want to understand the process of solving for the arbitrary unknown variables and it's application to solving for the equation should it instead be something like $\log$ or some other type of function. Additionally, I would have to take more "samples" of $\theta$ in order to get more accurate $x$ and $y$ coordinates.


I've tried looking at this similar question and this question, both of which did not actually supply the method for solving the simultaneous equation and declaring them mathematically impossible.

$\endgroup$
2
  • $\begingroup$ I noticed that you used the (systems-of-equations)-tag. Does this mean you meant write: $$\begin{cases} \frac X{1.5}=\cos(\theta_1)+\cos(\theta_1+\theta_2) \\ \frac Y{1.5}=\sin(\theta_1)+\sin(\theta_1+\theta_2)\end{cases}?$$ If so this can be writen as \begin{cases} \frac X{1.5}=\cos(\theta_1)+\cos(\theta_1+\theta_2) \\ \frac Y{1.5}=\sin(\theta_1)+\sin(\theta_1+\theta_2)\end{cases}. If not then the (systems-of-equations)-tag probably should be removed. $\endgroup$
    – gebruiker
    Dec 24, 2015 at 10:07
  • $\begingroup$ @gebruiker If that is the symbol for systems of equations, then yes. I don't think I've actually see systems of equations written like that a lot in my math textbooks. $\endgroup$ Dec 24, 2015 at 10:11

3 Answers 3

2
$\begingroup$

There is no general method for solving every system of non-linear equations. However, the system you stated does have a reasonable solution, and comes up in robotics, specifically, solving the inverse kinematics of a 2 link arm.

Suppose we have the following 2 link arm with link lengths $l_1,l_2 > 0$, and we wish to find the joint angles $\theta_1,\theta_2$ to get the end of the second joint in the desired position $(x,y)$.

http://www.cs.dartmouth.edu/~devin/cs81/lectures/lecture04/inverse2r.png

For a given $\theta_1,\theta_2$, the position of the end of the 2nd link is given by: $$x = l_1\cos\theta_1+l_2\cos(\theta_1+\theta_2)$$ $$y = l_1\sin\theta_1+l_2\sin(\theta_1+\theta_2).$$

(Note that if you substitute $l_1 = l_2 = 1.5$, you get the system in your question).

We can solve this problem either algebraically, or geometrically. I'll do it geometrically.

Using the Law of Cosines, we get that $\cos C = \dfrac{l_1^2+l_2^2-(x^2+y^2)}{2l_1l_2}$.

Hence, $\cos\theta_2 = \cos(180^{\circ}-C) = - \cos C = \dfrac{x^2+y^2-l_1^2-l_2^2}{2l_1l_2}$.

Therefore, $\theta_2 = \pm\arccos\left(\dfrac{x^2+y^2-l_1^2-l_2^2}{2l_1l_2}\right)$. Note that there are 2 solutions, one where the arm looks like the diagram above, and another where the arm is bent in the other direction.

Also, from using the Law of Cosines, we get $B = \pm \arccos\left(\dfrac{(x^2+y^2)+l_1^2-l_2^2}{2l_1\sqrt{x^2+y^2}}\right)$.

Using basic right angle trigonometry, we have $\theta_1+B = \text{atan2}(y,x)$.

Therefore, $\theta_1 = \text{atan2}(y,x) \mp \arccos\left(\dfrac{(x^2+y^2)+l_1^2-l_2^2}{2l_1\sqrt{x^2+y^2}}\right)$. Note that the $-$ solution for $\theta_1$ is paired with the $+$ solution for $\theta_2$, and the $+$ solution for $\theta_1$ is paired with the $-$ solution for $\theta_2$.

$\endgroup$
1
$\begingroup$

HINT...you could start by writing your equations as $$2\cos\frac{2\theta_1+\theta_2}{2}\cos\frac{2\theta_1-\theta_2}{2}=\frac{X}{1.5}$$ And $$2\sin\frac{2\theta_1+\theta_2}{2}\cos\frac{2\theta_1-\theta_2}{2}=\frac{Y}{1.5}$$ Now divide these equations and obtain$$2\theta_1+\theta_2=2\arctan\frac YX+n\pi$$

You can then substitute for $\theta_2$ into one of the original equations, expand the compound angle term and then use a compound angle transformation to obtain a solvable equation for $\theta_1$

$\endgroup$
7
  • $\begingroup$ I'm having trouble understanding why you divided and multiplied by 2. Could you have used any number? Additionally where and what does $n\pi$ represent? Are you using some special trigonometric rules? My math knowledge is limited to AP Calculus, so I may not be able to understand more advanced techniques without more intermediate steps, other-wise I have to trust that you derived the equation correctly and attempt the suggested substitution, expansion and compound transformation from there. $\endgroup$ Dec 24, 2015 at 18:37
  • $\begingroup$ For the first step I am using the Factor Formulae examsolutions.net/maths-revision/core-maths/trigonometry/… $\endgroup$ Dec 24, 2015 at 18:42
  • $\begingroup$ The $m\pi$ comes from the general solution for $\tan$ mathsfirst.massey.ac.nz/Trig/TrigGenSol.htm $\endgroup$ Dec 24, 2015 at 18:44
  • $\begingroup$ Looks like the trick to solving this problem was all in the Factor Formulae. Is there a derivation process for an $n$ number of cos(x)+cos(y)'s? $\endgroup$ Dec 25, 2015 at 4:17
  • $\begingroup$ I'm not sure what you're asking $\endgroup$ Dec 25, 2015 at 8:00
1
$\begingroup$

here is another way to do this. square the two equations and adding them gives you $$\frac1{2.25}(x^2 + y^2) = 2 + 2(\cos \theta_1\cos(\theta_1+\theta_2)+\sin \theta_1\sin(\theta_1+\theta_2)=2+2\cos \theta_2 $$ that is $$\theta_2 = \pm\cos^{-1}\left(\frac1{4.50}(x^2+y^2) - 1\right) $$ now use this value in the equation $$\cos \theta_1 + \cos (\theta_1 + \theta_2)=\frac x{1.5} $$ to find $\theta_1.$

$\endgroup$
1
  • $\begingroup$ You can make the formula for $\theta_2$ a little nicer. Since $1+\cos\theta_2= 2\cos^2\frac{\theta_2}{2}$, we have $$\frac{x^2+y^2}{9} = \cos^2\frac{\theta_2}{2}\quad\to\quad \cos\frac{\theta_2}{2} = \pm\frac{\sqrt{x^2+y^2}}{3}$$ $\endgroup$
    – Blue
    Dec 29, 2015 at 3:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .