Why is it so hard for MATLAB to solve the following symbolic equation

8 views (last 30 days)
syms rp alpha beta theta psi z
A=cos(alpha)-cos(beta);
B=sin(alpha)-sin(beta);
C=(cos(beta)-1)/tan(beta)-(cos(alpha)-1)/tan(alpha);
R=A*(cos(theta)-cos(psi))+B*cos(theta)*sin(psi);
S=A*sin(theta)*sin(psi)-B*cos(theta)+C*cos(psi);
phi=atan(-R/S)
x=-rp*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi))*cos(alpha)-rp*(-cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
y=-cos(psi)*sin(phi)*rp;
p=[x;y;z]
T=Rot('y',theta)*Rot('x',psi)*Rot('z',phi);
a1=T*[rp;0;0];
a2=T*[rp*cos(alpha);rp*sin(alpha);0];
a3=T*[rp*cos(beta);rp*sin(beta);0];
Con1=(p+a1)'*[0;1;0]
Con2=(p+a2)'*[-sin(alpha);cos(alpha);0]
Con3=(p+a3)'*[-sin(beta);cos(beta);0]
Any help is apperciated ! Thanks
  4 Comments
HN
HN on 27 Aug 2020
Edited: HN on 27 Aug 2020
Walter Roberson, sorry for incomplete information. Here it is
function output=Rot(axis,angle)
syms x y z
if axis==x
output=[1,0,0;0,cos(angle),-sin(angle);0,sin(angle),cos(angle)];
end
if axis==y
output=[cos(angle),0,sin(angle);0,1,0;-sin(angle),0,cos(angle)];
end
if axis==z
output=[cos(angle),-sin(angle),0;sin(angle),cos(angle),0;0,0,1];
end

Sign in to comment.

Accepted Answer

Alan Stevens
Alan Stevens on 27 Aug 2020
This seems to work
syms rp alpha beta theta psi z
A=cos(alpha)-cos(beta);
B=sin(alpha)-sin(beta);
C=(cos(beta)-1)/tan(beta)-(cos(alpha)-1)/tan(alpha);
R=A*(cos(theta)-cos(psi))+B*cos(theta)*sin(psi);
S=A*sin(theta)*sin(psi)-B*cos(theta)+C*cos(psi);
phi=atan(-R/S);
x=-rp*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi))*cos(alpha)-rp*(-cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
y=-cos(psi)*sin(phi)*rp;
p=[x;y;z];
T=Rot('y',theta)*Rot('x',psi)*Rot('z',phi);
a1=T*[rp;0;0];
a2=T*[rp*cos(alpha);rp*sin(alpha);0];
a3=T*[rp*cos(beta);rp*sin(beta);0];
Con1=(p+a1)'*[0;1;0];
Con2=(p+a2)'*[-sin(alpha);cos(alpha);0];
Con3=(p+a3)'*[-sin(beta);cos(beta);0];
disp([Con1; Con2; Con3])
function output=Rot(axis,angle)
syms x y z
if axis==x
output=[1,0,0;0,cos(angle),-sin(angle);0,sin(angle),cos(angle)];
end
if axis==y
output=[cos(angle),0,sin(angle);0,1,0;-sin(angle),0,cos(angle)];
end
if axis==z
output=[cos(angle),-sin(angle),0;sin(angle),cos(angle),0;0,0,1];
end
end
  6 Comments
Alan Stevens
Alan Stevens on 27 Aug 2020
I'm afraid I don't understand your program enough to help with the derrivatives.
HN
HN on 27 Aug 2020
syms dth dpsi
dphi=simplify(diff(phi,theta)*dth+diff(phi,psi)*dpsi);
dx1=(diff(x,theta)*dth+diff(x,psi)*dpsi+diff(x,Phi)*dphi)
:
:
It is like as shown above.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!