Flag to switch quaternion definition from Hamiltonian to JPL Convention for the scalar?

Is there a way to switch the quaternion definition of s,i,j,k to i,j,k,s. I'm trying to interface this with an existing system that can't be modified, but it looks like I'm going to have to build my own (probably just import a python one) quaternion library to be compatible with this other system I'm interfacing with instead of using the default MATLAB functions.
Thanks!

 Accepted Answer

I think all of the MATLAB functions are s,i,j,k. I am unaware of any functions that allow for i,j,k,s. You will probably have to build your own interface, or just do everything with a library that does what you need.
Also, be aware that Hamilton vs JPL isn't just about the scalar placement convention. It is also about right-handed vs left handed. I.e.,
Hamilton right-handed has i*j = k, j*k = i, and k*i = j (like right-handed cross product of coordinate axes)
JPL left-handed has i*j = -k, j*k = -i, and k*i = -j (like left-handed cross product of coordinate axes)
MATLAB uses Hamilton right-handed convention.
Packages like Unity use JPL left-handed convention. (A very poor choice IMO)
This can lead to all kinds of trouble when writing code and interpreting results, especially when one inadvertently pulls formulae from online sites that are Hamilton convention (but don't tell you that) and expect them to work when plugged into a package like Unity. Or vice-versa. Results can seem backwards or opposite of expectations if you are not careful.

1 Comment

Yeah for sure. Hence I would rather just not use the library at all and a different one since the L to R rotation would be impossible to keep track and make testing anxiety inducing. Thanks for the quick response.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!