|
"Peter " <paraplykongen@hotmail.com> wrote in message <i8mrv6$qrq$1@fred.mathworks.com>...
> Hi everybody.
> I have the following equations:
>
> x = -cos(theta_1)*sin(theta_2)*a_3*sin(theta_3)+cos(theta_1)*cos(theta_2)*a_3*cos(theta_3)-cos(theta_1)*a_2*sin(theta_2)+a_1*cos(theta_1);
>
> y = -sin(theta_1)*sin(theta_2)*a_3*sin(theta_3)+sin(theta_1)*cos(theta_2)*a_3*cos(theta_3)-sin(theta_1)*a_2*sin(theta_2)+a_1*sin(theta_1);
>
> z = cos(theta_2)*a_3*sin(theta_3)+sin(theta_2)*a_3*cos(theta_3)+a_2*cos(theta_2)+d_1;
>
> a_1, a_2, a_3 and d_1 are just some known coefficients.
>
> x, y and z are my inputs, e.g. (x = 400, y = 0, z = 700).
>
> Hence, we have 3 equations with 3 unknowns (theta_1, theta_2 and theta_3). How can I make MatLab solve theta_1, theta_2 and theta_3 numerically with x,y,z as my input?
>
> Thank you very much.
- - - - - - - -
There is an analytic solution to your problem. To shorten the equations, substitute a, b, c, d for a_1, a_2, a_3, and d_1, respectively, and p, q, and r for theta_1, theta_2, and theta_3, respectively. Then your equations can be expressed in equivalent form as:
x = c*cos(p)*cos(q+r)-b*cos(p)*sin(q)+a*cos(p);
y = c*sin(p)*cos(q+r)-b*sin(p)*sin(q)+a*sin(p);
z = c*sin(q+r)+b*cos(q)+d;
or
x = (+c*cos(q+r)-b*sin(q)+a)*cos(p);
y = (+c*cos(q+r)-b*sin(q)+a)*sin(p);
z-d = c*sin(q+r)+b*cos(q);
From this we can obtain
c*cos(q+r)-b*sin(q) = (+or-)sqrt(x^2+y^2)-a
c*sin(q+r)+b*cos(q) = z-d
The quantities on the right side are all known. By an odd coincidence these equations are equivalent to a pair of equations which was solved Sept. 25 by Bruno and myself in the thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/292359
to which I refer you. From the values of q and r solved from this you can then easily obtain p from the x and y equations using the atan2 function.
Roger Stafford
|