# [osg-users] Quaternion Multiply

Mon Sep 15 05:22:23 PDT 2008

```The quaternion multiplication is not consistent with the matrix multiplication (which was pointed out on the list with example as well).

Even worse the osg matrix multiplication is not consistent with the glsl matrix multiplication.

Richard

-----Ursprüngliche Nachricht-----
Von: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-bounces at lists.openscenegraph.org] Im Auftrag von J.P. Delport
Gesendet: Sonntag, 14. September 2008 14:06
An: OpenSceneGraph Users
Betreff: Re: [osg-users] Quaternion Multiply

Hi,

the matrix pre vs postmultiply (row and column major) issue comes up
every now and again on the list, so also see the mailing list archives:

http://news.gmane.org/gmane.comp.graphics.openscenegraph.user

Basically, OSG follows a (consistent) matrix multiplication order
convention that seems to differ from what most people expect first time
around.

The quaternion multiplication order was made so that the order is
consistent with the matrix mult order used by OSG.

The best way to sort this out for yourself is to write a rotation
problem out on paper and then implement the same thing as a matrix and
quaternion operation in OSG.

See the code in osgunittests for the quaternion tests. There is also
code in OSG to print out the values of matrices and quaternions that can
help.

regards
jp

Matt Sutton wrote:
> Hi Folks,
>
>    I know I must be missing something, but can someone help me out with
> this.  It is true that multiplying two quaternions, a and b, can be seen
> as a linear transform of one on the other, right?  So, for quaternions
> a, b and c you can have something like:
>
>
>
> c = a*b
>
>
>
> Option 1: Using a linear transform on b constructed from a
>
> c = A*b
>
> Option 2: Using a linear transform on a constructed from b
>
> c = B*a
>
>
>
> Note that matrices A and B have a slightly different construction since
> the product of two quaternions is not commutative.
>
>
>
> But, it looks to me like the OSG implementation is effectively using
> option 1, but constructing the "A" matrix from the b quaternion? So, it
> looks like a*b is actually b*a.  Is that intended?   If I'm totally
> seeing this wrong, please forgive me.  I've attached a test file.
>
>
>
> Thanks,
>
> Matt Sutton
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.

_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

```