SimScape multibody rotation matrix

Hello everyone,
I am currently working with simscape multibody and trying to determine a rotation matrix for a rigid transform. Let's assume I have an extruded solid along its z axis and the coordinate of the director vector of the rotation axis of the revolute joint is known QP=[-7 32.7 94.2]. (New origin has to be M=[129.9984 145.1076 353.5218].)
Now I want to calculate the rotation matrix needed to transform the wolrd frame's Z axis so it matches the joint's axis. For that, I caculate first the angle around the X axis, by calculating the angle between the projection of the vector on the YZ plane and the Z axis (-19.1436°), then caculate the angle around the Y axis calculating the angle between the projection of the vector on the XZ plane and the Z axis (-4.2498°).
After that, I determine rotx(theta1) and roty(theta2), and determine the final rotation matrix R=rotx*roty.
To verify my calculation, I multiply Z axis coordinate by the rotational matrix and get QP' [-7.4106 32.7035 94.2102].
Element by element division QP/QP' gives me [0.9446 0.9999 0.9999], which means the rotation matrix is incorrect.
When keeping the same method for the X axis rotation and calculating the angle between QP (coordinate in the new base after the X rotation) and Z axis, I obtain an angle of -4.0156°. The new QP/QP' gives [-1.0581 -0.9971 0.9996], which is still wrong.
Would you have an idea on what is wrong? Thank you for your answers.
rS5x=Zvector(1,2)*rQP(1,3)-Zvector(1,3)*rQP(1,2); %get the sign of the angles (Xa-Yb)*(Ya-Xb)
rS5y=Zvector(1,3)*rQP(1,1)-Zvector(1,1)*rQP(1,3);
rtheta5x=sign(rS5x)*acos(dot([0 rQP(1,2) rQP(1,3)],Zvector)/(norm(Zvector)*norm([0 rQP(1,2) rQP(1,3)])))*180/PI; %angle around X axis
rR5x=rotx(rtheta5x); %rot matrix X
rQPprime=rQP*rR5x; %rQP coordinate in new base
rtheta5y=sign(rS5y)*acos(dot([rQPprime(1,1) 0 rQPprime(1,3)],Zvector)/(norm(Zvector)*norm([rQPprime(1,1) 0 rQPprime(1,3)])))*180/PI; %angle around Y axis
rR5y=roty(rtheta5y); %rot matrix Y
rR5=rR5x*rR5y; % global rot matrix
VerifQP=Zvector*rR5*100; %QP calculated from Z axis and rot matrix
AB=rQP./VerifQP; %element by element division

3 Kommentare

James Tursa
James Tursa am 15 Feb. 2021
Can you post an image of how things are related?
Killian Hyron
Killian Hyron am 15 Feb. 2021
Bearbeitet: Killian Hyron am 15 Feb. 2021
Here you can see points Q and P and all the suspension mechanism. X Axis is along the car (from right to left on the picture), Z is vertical and Y horizontal (from center to the left wheel here)
Killian Hyron
Killian Hyron am 16 Feb. 2021
Hi James,
Little update : By calculating the axis of rotation between Zvector and QP, and deducing the rotation matrix from it, I get QP/QP' = [-0.9996 -0.9996 0.9996], which is way better (but unfortunately not entirely precise)!
I am still wondering what is wrong in my first method.
The 2 different matrixes are :
Rot5 =
0.9975 0.0118 -0.0700
0.0118 0.9449 0.3271
0.0700 -0.3271 0.9424 Second method
rR5 =
0.9975 0 -0.0700 First method
0.0230 0.9447 0.3271
0.0662 -0.3279 0.9424
As we can see, Rot5 is almost antisymmetric, and rR5 isn't at all. Do you have an idea of the problem of the first method?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Gefragt:

am 15 Feb. 2021

Kommentiert:

am 16 Feb. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by