[ODE] FW: Quick dQuaternion question

Jon Watte (ODE) hplus-ode at mindcontrol.org
Tue Jun 13 10:15:42 MST 2006

```X rotated around Y always yield -Z, both in left-handed interpretation
and right-handed interpretation. (this is why rotations use the left
hand rule in left-handed systems, and the right hand rule in
systems mixed up in your question.

Note that "A physically clockwise rotation around Y" is expressed as
negative angles in right-handed systems, but as positive angles in a
left-handed system. The crucial realization is that "clockwise" or
"physical" is an interpretation domain constraint, not math.

Think of it this way: if you convert the quaternions to matrices,
multiply the matrices, and then convert back to quaternion, that's what
you get when you multiply quaternions directly. Thus, because matrix
multiplication is handedness neutral, and quaternion/matrix conversion
is handedness neutral, then quaternion multiplication must be handedness
neutral.

As the FAQ says: feed ODE left-handed data; then the data you pull out
is left-handed.

Cheers,

/ h+

Auro wrote:
> Hmm.... this is new for me.
>
> Matrices don't have handedness I quite understand, but quaternions?
> Without handedness how would you multiply two quaternions (or convert
> from quats to matrices)? Let me state my point - pls correct me if I'm
> wrong:
>
> q1= A + iB + jC + kD
> q2= E + iF + jG + kH
>
> If you want to compute q3 = q1*q2, you'd have to decide on the following
> rules:
> i*j=?; j*i=?
> j*k=?;  k*j=?
> k*i=?; i*k=?
> (and you'd of course have  i*i=j*j=k*k=-1)
>
> In a right-handed system the rules would be:
> i*j=k; j*i= -k
> j*k=i;  k*j= -i
> k*i=j; i*k= -j
> and therefore:
> q3 = (AE - BF - CG - DH) + i(AF + BE + CH - DG) + j(AG - BH + CE + DF) +
> k(AH + BG - CF + DE)
>
> And in a left-handed system the rules would be:
> i*j= -k; j*i=k
> j*k= -i;  k*j=i
> k*i= -j; i*k=j
> and therefore:
> q3 = (AE - BF - CG - DH) + i(AF + BE - CH + DG) + j(AG + BH + CE - DF) +
> k(AH - BG + CF + DE)
>
> Similar differences can be found when you write the equations for
> converting quats to matrices, and that would be important while setting
> the transformation matrices in opengl or directx.
>
> And looking at the ODE code (dQMultiply0, dRtoQ, dQtoR), it'd seem to me
> that ODE is consitently right-handed. therefore while working with
> opengl things would work just fine.
>
> Perhaps I'm not seeing the obvious since you state it so strongly that
> ODE is handedness free - cud you please clarify.
>
> Thanks and Cheers,
>  -Auro
>
>
> On 6/12/06, *Jon Watte (ODE)* <hplus-ode at mindcontrol.org
> <mailto:hplus-ode at mindcontrol.org>> wrote:
>
>
>     Please just check your math. Neither quaternions, nor matrices, nor ODE
>     have handedness. Only the interpretation of the data by you has
>     handedness. If you put in left-handed data into ODE, and run the
>     simulation, then the data you get out is left-handed. This is just a
>     basic truth of mathematics; ODE doesn't need to (and does not) interpret
>     the handedness of data at all.
>
>     Cheers,
>
>                             / h+
>
>
>     Auro wrote:
>      > Hi Jon,
>      >
>      > can u plz explain the "Handedness neutral" bit? How can ODE be
>      > handedness neutral - how can it even guess the handedness in the
>     first
>      > place. Besides quaternions in themselves have no handedness -
>     that comes
>      > into play only when u do a quat -> matrix conversion or the
>     reverse. And
>      > looking at the ODE code (quat -> matrix conversion) I'd say that
>     ODE is
>      > very much right-handed while DirectX is left-handed (OpenGL again is
>      > right handed).
>      > Thanks beforehand.
>      > Cheers,
>      >
>      >  -Auro
>      >
>      >
>      > On 6/5/06, *Jon Watte (ODE)* <hplus-ode at mindcontrol.org
>     <mailto:hplus-ode at mindcontrol.org>
>      > <mailto:hplus-ode at mindcontrol.org
>     <mailto:hplus-ode at mindcontrol.org>>> wrote:
>      >
>      >
>      >     No, you should not. You only need to change the order. ODE is
>      >     "handedness neutral" -- if you put in left-handed coordinates
>     and data,
>      >     you will get out left-handed coordinates and data.
>      >
>      >     Cheers,
>      >
>      >     / h+
>      >
>      >
>      >     justinleung at imagi.com.hk <mailto:justinleung at imagi.com.hk>
>     <mailto: justinleung at imagi.com.hk <mailto:justinleung at imagi.com.hk>>
>     wrote:
>      >      > >From my expriement to integrate quaternion in ODE to DirectX,
>      >     beside the order
>      >      > of W X Y Z, i need to invert the sign of X Y Z ( i.e. -X,
>     -Y and
>      >     -Z) for correct
>      >      > result. Is it normal?
>      >      >
>      >      > Justin
>      >      >
>      >      >
>      >
>      >
>      >     _______________________________________________
>      >     ODE mailing list
>      >     ODE at q12.org <mailto:ODE at q12.org> <mailto:ODE at q12.org
>     <mailto:ODE at q12.org>>
>      >     http://q12.org/mailman/listinfo/ode
>     <http://q12.org/mailman/listinfo/ode>
>      >
>      >
>      >
>      >
>      >
>      > --
>      > -----------------------------
>      > - Aurobrata Ghosh -
>      > +91-9873159692
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>
>      >
>      > _______________________________________________
>      > ODE mailing list
>      > ODE at q12.org <mailto:ODE at q12.org>
>      > http://q12.org/mailman/listinfo/ode
>     <http://q12.org/mailman/listinfo/ode>
>
>
>
>
> --
> -----------------------------
> - Aurobrata Ghosh -
> +91-9873159692
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
```