sanostol Posted October 27, 2008 Share Posted October 27, 2008 (edited) Hi I'm trying to do a quaternion dot product in vex. for this i fetched 2 transforms from the objectlevel, i use to nulls. with the optransform(thanks sidefx for fixing it ) i get the matrix4, after converting them to matrix3 and quaternion I do the dot product of them matrix3 $basematrix = optransform($base); matrix3 $targetmatrix = optransform($target); $basequat = quaternion($basematrix); $targetquat = quaternion($targetmatrix); $dot = $basequat[0]*$targetquat[0] + $basequat[1]*$targetquat[1] + $basequat[2]*$targetquat[2] + $basequat[3]*$targetquat[3]; but somehow the quaternions and the dot do not behave like expected the base object stands still, rx, ry rz are zero the targetobject is rotatet around y from -360 to 360, at at the blue bar the roation is 0 here is a motionview of what is going on on the quaternions of the target null from -360 < ry 360: and finally the dot product: i expected something like - 1 to 1 to -1 with no breaks in it what's going wrong? are the quaternions non normalized? i attached the file quatprob.zip Edited October 28, 2008 by sanostol Quote Link to comment Share on other sites More sharing options...
sibarrick Posted October 28, 2008 Share Posted October 28, 2008 You might find that instead of just extracting the quaternion from the matrix that you are better off transforming a base quaternion identity by the matrix to get the target quaternion. I can't remember if this is the method I used for my quaternion deformers, I think it is, I'll take a look when I'm back at my machine with it on. Quote Link to comment Share on other sites More sharing options...
sanostol Posted October 28, 2008 Author Share Posted October 28, 2008 Thanks Sibarrick but how can I transform a quaternion with a rotation matrix, other than that I have to convert the matrix to a quaternion to multiply. could not find a vex function for this Quote Link to comment Share on other sites More sharing options...
edward Posted October 28, 2008 Share Posted October 28, 2008 I think you should read up a bit more on quaternions. There are several misunderstandings about quaternions: - given the quatenion q, -q and +q represent the same rotation. the discontinuities are expected. the usual way to perform slerp interpolation is to negate one of the quaternions before performing the interpolation if the dot product of the two quaternions is negative in order to ensure a shortest path rotation. - as a result of these discontinuities, the dot product will also exhibit discontinuities at the same time because of the quaternion flipping - multiplying quaternions is the cross product of the two 4 dimensional quantities, it is NOT a dot product. if you want to rotate a point, then it's neither a just a cross product nor a dot product, you should look up on how to properly do this. BTW, you can just multiply two quaternions together in VEX, it will do the right thing (ie. cross product). Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted October 28, 2008 Share Posted October 28, 2008 On the debatable benefits of quaternions as the preferred tool for performing SLERPs: http://www.gamedev.net/reference/articles/article1199.asp Interesting read. Quote Link to comment Share on other sites More sharing options...
edward Posted October 28, 2008 Share Posted October 28, 2008 Yes, but take into account the italic print at the top of the article: ... we've come to feel that this article contains misinformation (as many have pointed out) that could prove to be confusing and misleading to the many beginners who turn to us as a source of information Quote Link to comment Share on other sites More sharing options...
edward Posted October 28, 2008 Share Posted October 28, 2008 I do agree however, that one should carefully consider how to perform quaternion interpolation, especially if one needs performance. One of the better ones: - http://number-none.com/product/Understandi...t%20Using%20It/ Another good quaternion article: - http://www.cs.cmu.edu/~spiff/moedit99/ Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted October 28, 2008 Share Posted October 28, 2008 Yes, but take into account the italic print at the top of the article: Yup. That's why I'm cautiously labeling it as "interesting read" What do you make of it? Are the objections mere academic nit-picking? Or truly flawed understanding? I simply don't have the necessary background to form an intelligent opinion; but you do. So waddya think, Ed? [EDIT] Ooops... guess we posted at the same time. Thanks for the references! [/EDIT] Quote Link to comment Share on other sites More sharing options...
edward Posted October 28, 2008 Share Posted October 28, 2008 I read that article a long time ago and so I don't remember all its problems anymore. As I recall, I skipped over most of the math since it wasn't really anything new so I don't know if her math is correct but it probably is. It's mostly that her arguments against quaternions are very one sided. Take for example, 4. Quaternion operations don't require trig, vector operations do.A. Don't get too hung up on this. A dot product is a cosine whether you are talking about vectors or quaternions. But there's a big difference here between computing cos() using the dot product and computing cos() by invoking the CPU instruction. Ultimately, the article is just a rant against blindly using quaternions as a magic bullet for everything, which I agree since I don't believe in magic bullets. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted October 28, 2008 Share Posted October 28, 2008 Ultimately, the article is just a rant against blindly using quaternions as a magic bullet for everything, which I agree since I don't believe in magic bullets. Thanks for your valued opinion. That was the feeling I got while reading it too -- a warning against blind usage. Cheers! Quote Link to comment Share on other sites More sharing options...
sanostol Posted October 28, 2008 Author Share Posted October 28, 2008 (edited) I think you should read up a bit more on quaternions. There are several misunderstandings about quaternions:- given the quatenion q, -q and +q represent the same rotation. the discontinuities are expected. the usual way to perform slerp interpolation is to negate one of the quaternions before performing the interpolation if the dot product of the two quaternions is negative in order to ensure a shortest path rotation. - as a result of these discontinuities, the dot product will also exhibit discontinuities at the same time because of the quaternion flipping - multiplying quaternions is the cross product of the two 4 dimensional quantities, it is NOT a dot product. if you want to rotate a point, then it's neither a just a cross product nor a dot product, you should look up on how to properly do this. BTW, you can just multiply two quaternions together in VEX, it will do the right thing (ie. cross product). Hi Edward, in this case I want the dot product, and I don't want the shortest path for rotation. I'm doing my own slerp, and for this i need the sign. Consider a long neck that spins around 180 degree and then decides for the shortes path. I did a operator for spines and stuff like that in another software this way, and it is able to spin around in every direction up 360 degrees this way,without flipping at 180. so I really want this sign Thanks for the links, I guess You can never read to much about stuff like that Edited October 28, 2008 by sanostol Quote Link to comment Share on other sites More sharing options...
edward Posted October 28, 2008 Share Posted October 28, 2008 I'd be curious to see the result. The thing to be careful about is that obtaining a quaternion from a matrix is a tricky proposition at best, don't expect to get consistent directions out of the conversion. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted October 28, 2008 Share Posted October 28, 2008 Thanks Sibarrickbut how can I transform a quaternion with a rotation matrix, other than that I have to convert the matrix to a quaternion to multiply. could not find a vex function for this Seems I mis-remembered, been a long time since I looked at this. I also use the same method you have but I've never had the flipping issue, probably because I've always required the shortest path blending. I'm sure I have come across a solution to this somewhere though, racking my brain now to think of where.... Quote Link to comment Share on other sites More sharing options...
sanostol Posted November 22, 2008 Author Share Posted November 22, 2008 (edited) Calculon is still thinking I thing I understood the problem and the possible solution. it lies in the nature of the matrix to quaternion conversion. i did it manualy (inlinecode) and it is the sqrt function that makes it impossible to keep the sign. not a problem if You need the shortes path. but in my case I found that the euler to matrix conversion does the trick. continuous quaternions, yeah. what a wonderfull (houdini)world does anybody know how to collect all quaternions of all parentobjects easily by converting their eulers to quaternions in houdini recursivly. Seems I mis-remembered, been a long time since I looked at this. I also use the same method you have but I've never had the flipping issue, probably because I've always required the shortest path blending.I'm sure I have come across a solution to this somewhere though, racking my brain now to think of where.... Edited November 22, 2008 by sanostol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.