Commands for Simulations using Quaternions

3 次查看(过去 30 天)
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:
  1. quaternion
  2. quatmultiply
  3. quatconj
  4. quatinv
Please guide so that I can buy at the earliest.
Regards,
Zaid

回答(1 个)

James Tursa
James Tursa 2020-5-7
编辑:James Tursa 2020-5-7
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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by