[osg-users] Quaternion multiplication order
Will Dicharry
wdicharry at gmail.com
Tue Oct 16 12:35:22 PDT 2007
Hello,
I noticed that the cross terms in osg's quaternion class binary
multiplication differ from the usual mathematical definition of quaternion
multiplication. The subtractions are opposite what they should be.
osg's implementation is
/// Binary multiply
inline const Quat operator*(const Quat& rhs) const
{
return Quat( rhs._v[3]*_v[0] + rhs._v[0]*_v[3] + rhs._v[1]*_v[2] -
rhs._v[2]*_v[1],
rhs._v[3]*_v[1] - rhs._v[0]*_v[2] + rhs._v[1]*_v[3] + rhs._v[2]*_v[0],
rhs._v[3]*_v[2] + rhs._v[0]*_v[1] - rhs._v[1]*_v[0] + rhs._v[2]*_v[3],
rhs._v[3]*_v[3] - rhs._v[0]*_v[0] - rhs._v[1]*_v[1] - rhs._v[2]*_v[2] );
}
I believe that it should be:
/// Binary multiply
inline const Quat operator*(const Quat& rhs) const
{
return Quat(
rhs._v[3]*_v[0] + rhs._v[0]*_v[3] - rhs._v[1]*_v[2] + rhs._v[2]*_v[1],
rhs._v[3]*_v[1] + rhs._v[0]*_v[2] + rhs._v[1]*_v[3] - rhs._v[2]*_v[0],
rhs._v[3]*_v[2] - rhs._v[0]*_v[1] + rhs._v[1]*_v[0] + rhs._v[2]*_v[3],
rhs._v[3]*_v[3] - rhs._v[0]*_v[0] - rhs._v[1]*_v[1] - rhs._v[2]*_v[2] );
}
The effect of this transposition is to force a pre-multiplication ordering
for the operation. I am wondering whether this is intentional or a mistake
and if it is intentional, why was it chosen to work this way. I searched
the osg mailing list archives, and I found a similar question posted in
2004, but I haven't been able to find a follow up to that message.
This causes problems in my application because I may receive orientation
data from a source that uses a different quaternion library using the
post-multiplication ordering, which is the standard way in the mathematical
community.
Thanks,
Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071016/278050e4/attachment-0002.htm>
More information about the osg-users
mailing list