--- On Tue, 21/4/09, J.P. Delport <jpdelp...@csir.co.za> wrote: > From: J.P. Delport <jpdelp...@csir.co.za> > Subject: [osg-users] Quat * Vec3 proposals - request for comments/help > To: "osg users" <firstname.lastname@example.org> > Date: Tuesday, 21 April, 2009, 1:36 PM > Hi all, > > it's been known for a while  that there are > inconsistencies with the way OSG handles Quat * Vec3. In > short: Quat * Vec3 is written in code as a post-multiply, > but the result of the operation is as if a pre-multiply was > performed. The attached test app also shows the problem > (more on it later). > >  > http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/21003 > and > http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/33099 > > What doesn't work? > There are many examples that can be constructed of where a > mathematical expression usings quats and vectors would not > provide the expected results. See also . The easiest one > I could come up with is this: > > ((q1 * q2) * v) != (q1 * (q2 * v)) > > Why are there not more complaints?
Well I curse this all the time, but not for the same reason. For me it's q1 * q2 that's annoying as I see it as the opposite of what I expect from the mathematics of applying a quaternion to a vector but then therein lies the problem. Using operator* for matrix multiplications is fine as that mirrors precisely what you are doing with the matrices mathematically. Using operator* for quaternion multiplication is a loose analogy since you are actually doing q*v*q' mathematically when applying q to v. If you have two rotations, q1 followed by q2 then you would get q2*q1*v*q1'*q2' mathematically and so I expect the interpretation of operator* to allow me to write q2*q1*v in code. Of course that's just my interpretation and what I'm effectively saying within that interpretation is that it's quat * quat that is wrong but there's no way in the world you can swap that now! :) Alternatively you could drop osg::Vec3::operator*( osg::Quat ) altogether and have osg::Vec3::apply( osg::Quat ) or osg::Vec3::rotate( osg::Quat ). I've used math libraries that do it this way (and where vec::operator*( quat ) is just that i.e. the mathematical multiplication rather than the full blown rotation. I guess it depends on whether you value the brevity of operator* over the underlying mathematics. If operator* is still going to be used for applying a quaternion to a vector then I support the idea of making the multiplication orders consistent between quat/quat and vec/quat as per your proposal. Making it consistent with OSG's row-major matrix multiplication is probably easier for coders who are not concerned with the details of the maths (and as I noted above it's not a workable solution to swap it now anyway). Whatever happens I second the comment of Tanguy Fautre who asked for it to be documented clearly somewhere. :) Anyway I hope you don't mind me chipping in. It certainly is interesting that there hasn't been more discussion. Maybe people just do what works and leave it. ;) Paul Fotheringham. _______________________________________________ osg-users mailing list email@example.com http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org