From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Equations depicting 2 DOF
Date: Mon, 12 Apr 2010 13:35:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <hpv7ip$ett$>
References: <hpurlj$g9g$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1271079321 15293 (12 Apr 2010 13:35:21 GMT)
NNTP-Posting-Date: Mon, 12 Apr 2010 13:35:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:625804

"Imran " <> wrote in message <hpurlj$g9g$>...
> Dear All
> Good day
> I have to find solution to following two equations
> L1 Cos (theta1)+ L2 Cos (theta2)=x
> L1 Sin (theta1) + L2 Sin (theta2)=y
> here L1, L2, x and y are known
> is there any direct function available?
> best regards,
> imran

Do the following:

 L3 = sqrt(x^2+y^2);
 theta3 = atan2(y,x);
 theta1 = theta3 +/- acos((L3^2+L1^2-L2^2)/(2*L1*L3));
 theta2 = theta3 +/- acos((L3^2+L2^2-L1^2)/(2*L2*L3));

The "+/-" designation above means that you need to try all four combinations of signs at these two places, testing each of the four resulting possible solutions in the original equations.  Two of the solutions may be valid, or the arguments of the acos's could be out of range with no solution possible.  This depends on the values of the quantities, L1, L2, x, and y that are given.  Also the theta's in successful solutions may lie outside the range from -pi to +pi, in which case you are free to add or subtract multiples of 2*pi to them if you choose.

  I leave it as "an exercise for the student" to discover the reasoning involved here.  While you are doing this you may also discover a simpler criterion for choosing the unknown signs above.

Roger Stafford