Calculating angle for transformation from global coordinate system to local one

24 vues (au cours des 30 derniers jours)
Fabian Wolf
Fabian Wolf le 6 Mar 2016
Commenté : Fabian Wolf le 12 Mar 2016
Hey guys, I am stuck with the problem as described above. As an example let's say I have this situation:
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

Réponses (1)

Vaibhav Awale
Vaibhav Awale le 11 Mar 2016
Modifié(e) : Vaibhav Awale le 11 Mar 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
  1 commentaire
Fabian Wolf
Fabian Wolf le 12 Mar 2016
Hello Vaibhav,
thank you very much for your work! It is much appreciated.
With your calculations however I didn't get the correct results for my actual problem. I used the given example only to elaborate my problem in general. When using the steps on my actual problem I didn't get the results.
Excuse me, for not being more specific about my problem before.
Thank you again for your time and effort! I would be very grateful if you could further help me with this problem.
Regards,
Fabian

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by