Commands for Simulations using Quaternions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi MathWorks Team,
I am intersted to buy MATLAB Student Version for my PhD research. But I need a few specific commands related to quaternions. While going through vairous toolbox search, I doubt the commands are split across multiple toolbox. Please guide what is the cheapest way to buy MATLAB with following options:
- quaternion
- quatmultiply
- quatconj
- quatinv
Please guide so that I can buy at the earliest.
Regards,
Zaid
0 commentaires
Réponses (1)
James Tursa
le 7 Mai 2020
Modifié(e) : James Tursa
le 7 Mai 2020
Not to be flippant, but the cheapest way is to not buy a toolbox just for the functions you need, but simply write your own functions.
Represent quaternion as a simple double variable Nx4, where N = number of quaternions in the variable. Same as MATLAB.
Then the quatmultiply, quatconj, and quatinv functions would be trivial to write. E.g., if we assume scalar-vector order and right-handed Hamilton convention as MATLAB toolboxes do, then assuming you have a later version of MATLAB that uses implicit expansion:
function qc = quatconj(q)
qc = [q(:,1),-q(:,2:4)];
end
and
function qi = quatinv(q)
qi = quatconj(q) ./ sum(q.*q,2);
end
and
function r = quatmultiply(q,p)
qs = q(:,1);
ps = p(:,1);
qv = q(:,2:4);
pv = p(:,2:4);
r = [qs.*ps - dot(qv,pv,2), qs.*pv + ps.*qv + cross(qv,pv,2)];
end
If you wanted to use the (evil) left-handed JPL quaternion convention (which does not match MATLAB), then you would change the + cross(etc) to - cross(etc) in the quatmultiply( ) function.
If you do decide to get a toolbox, keep in mind that the quaternion convention used by the Aerospace Toolbox is different from the quaternion convention used by the Robotics Toolbox. The Aerospace Toolbox seems to be geared towards coordinate system transformation quaternions, and the Robotics Toolbox seems to be geared towards vector rotations within the same frame.
1 commentaire
Zaid Ahmad
le 8 Mai 2020
Thank you very much for your detailed answer, James. It was really helpful.
Voir également
Catégories
En savoir plus sur Quaternion Math 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!