From: Doug M. <mc...@ia...> - 2005-07-11 12:47:21
|
kevin meinert wrote: > I think when there is a scale in the matrix, that the quat you get is not > a rotation quat. a rotation quat by definition is unit length == 1. > having the scale in the matrix no longer means you're encoding pure > rotation, now you've got something more, rotation plus scale. translation > works because it's a completely separate part of the matrix, and so isn't > read during the conversion. the scale however (as i'm sure you know) > exists in the same values that encode rotation (the upper left 3x3 > coordinate axes). > > separating scale from the rotation in a matrix that encodes both is > slightly ambiguous, and apparently not supported by the well known > mat->quat algorithms found in the books and websites we used as reference > to write this code. I've never seen a variation on this algorithm, > though that doesn't mean it's not doable.... for now if you do want > scale you'll have to keep your scale matrix separated out from your other > transforms... (basically get your rotation quat _before_ you compose your > scale matrix into your matrix transform). > Thanks Kevin. That is what I discovered and the solution that I implemented as well. Everything works great once I grab scale out of the matrix before creating the quat. And just to verify, when grabbing scale out of a 4x4 you take the length of each of the first 3 column vectors? Thanks again. Doug > *--*---*---*----*-----*------*------*-----*----*---*---*--* > Kevin Meinert /_/ > http://www.subatomicglue.com \ / > \/ __ \/ > \__ > \_\ > > >>Hello, >> I am using gmtl 0.4.9. If I try to create a quat from this matrix I >>get the following: >> >>| 0.5 -0.866025 0 0 | >>| 0.866025 0.5 0 0 | >>| 0 0 1 0 | >>| 0 0 0 1 | >> >> quat >>(0, 0, 0.5, 0.866025) >> >>Which gives me the correct end rotation. Now, if I take the same matrix >>from above and apply a scale of 3 I get the following: >> >>| 1.5 -2.59808 0 0 | >>| 2.59808 1.5 0 0 | >>| 0 0 3 0 | >>| 0 0 0 1 | >> >> quat >>(0, 0, 0.981981, 1.32288) >> >>Which ends up over rotating by what appears to be a few degrees. It is my >>understanding that I should be able to create a quat with a matrix that >>does have scale on it, correct? >> >>Thanks for the help. >> >>Doug >> >> >> |