Calculating angle for transformation from global coordinate system to local one
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys, I am stuck with the problem as described above. As an example let's say I have this situation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156866/image.png)
In this example everything is calculated but let's suppose the angle 50° is unknown and I want to calculate it by only knowing
[0.204 -1.332; -1.332 3.796]
and
[1 2; 2 3]
So the problem is that I have an equation of the form:
Q*A*Q^T=b
Is it even possible to calculate the angle with Matlab? I thought I have to bring the problem to the form:
A*x=b
But I don't know how to do that with the transpose matrix Q^T in the way. And then I only have one unknown but 2 equations... In my actual problem in 3D I have 3 unknown angles, I just wanted to use this 2D example to showcase my problem.
I tried to solve it by expanding the 3 matrix products and calculate the angle by using a symbolic value and "solve" but the result was wrong...
Note that my actual problem is 3D, with 3 unknowns to calculate. I just wanted to use this easier example for describing my problem in general.
I hope you can point me in the right direction. Any help is much appreciated!
- Fabian
0 comentarios
Respuestas (1)
Vaibhav Awale
el 11 de Mzo. de 2016
Editada: Vaibhav Awale
el 11 de Mzo. de 2016
Hello Fabian,
You need to find the rotation matrix (in your case Q) from equation
Q*A*Q^T = B
After a little bit of algebra, I was able to find the following way to find rotation matrix:
[Da, eigA] = eig(A); % Find eigenvectors and eigenvalues of A
[Db, eigB] = eig(B); % Find eigenvectors and eigenvalues of B
Q = Db'*Da; % This relation can be derived if we substitute B = Db^T*eigB*Db and A = Da^T*eigA*Da in above equation and noting that eigA and eigB are same because it is a similarity transform
disp('QAQ^T'), disp(Q*A*Q'); % Check if Q*A*Q^T gives B
disp('B'), disp(B)
Now you can find out the angle of rotation and axis of rotation from the rotation matrix itself (i.e. in your case only "Q" matrix is enough).
The rotation angle is given by following formula:
rotation_angle = acos(0.5*trace(Q));
I carried out above steps on the example provided by you and got the correct result. I am attaching the script for reference. Note that for 3-D case, you need to use the following formula:
rotation_angle = acos(0.5*(trace(Q)-1));
I hope this helps and answers your question.
Regards,
Vaibhav
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!