Path: news.mathworks.com!not-for-mail From: "Imran " <imran.shafi@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Equations depicting 2 DOF Date: Mon, 12 Apr 2010 14:56:05 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 30 Message-ID: <hpvca5$7i4$1@fred.mathworks.com> References: <hpurlj$g9g$1@fred.mathworks.com> <hpv7ip$ett$1@fred.mathworks.com> Reply-To: "Imran " <imran.shafi@gmail.com> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1271084165 7748 172.30.248.37 (12 Apr 2010 14:56:05 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 12 Apr 2010 14:56:05 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2309164 Xref: news.mathworks.com comp.soft-sys.matlab:625841 thank you very much Roger I shall try it out and be back soon Imran "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hpv7ip$ett$1@fred.mathworks.com>... > "Imran " <imran.shafi@gmail.com> wrote in message <hpurlj$g9g$1@fred.mathworks.com>... > > 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