New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quaternions "(x,y,z,w) convention" quite misleading :( #2250
Comments
I wonder what @WestLangley thinks about this. |
@mrdoob Brief googling shows this seems to be pretty arbitrary convention (as is often the case in computer graphics) - e.g. DirectX, XNA, Unity or Maya use But this seems to be quite moot, anyways even with Blender you access quaternions mostly via named properties (e.g. I wasn't even aware it used wxyz). @apendua Are you aware there already is skeletal animation export for Blender? It's still bit rough around edges but it works (see #2106): http://alteredqualia.com/three/examples/webgl_crowd.html |
@alteredq I only became aware of this brand new exporter a few hours ago, while I was looking for some clues to find out what was wrong with my code. If there's anything I could help with - at least at the blender site - please keep me updated. Talking about this "quaternion convention"... what I was trying to say was not that it's not arbitrary - you could as well write zyxw or anything - but one of these orderings seems to be more natural than the others and the reasons for that are purely mathematical. Or, if it does not convince you, lets just agree that we should put the coordinates in the alphabetical order, like "uv coordinates" not "vu" ;) As you said, since quaternions are mostly used as black boxes - i.e. access through methods and props - the problem only occurs while importing or exporting the data into a file. So why not embed the information about quaternion encoding into the meta data section? Come on, if you decided to put the "generated by" attribute in there, the you could as well declare quaternion encoding. @mrdoob, @alteredq By the way, I've been also thinking about implementing some more advanced animation features for THREE.js, like action graphs / bone constraints / inverse kinematics. Do you have any suggestions where to start? This would definitely require some major modifications in the file format, so any guidance would be greatly appreciated :) |
@WestLangley I've never asked anyone to do so. In fact, I really appreciate your work guys and would never bother you with such a small problem, if it wasn't for the fact that at some point I wasted several hours of debugging, not being aware of the issue. My only goal was to bring this matter to the world, hoping that it saves someone's time in the future. But maybe it won't, since the only place where it really matters is the source code of animation exporter, which is already there :) |
Recently, I've been working on skeletal animation exporter from Blender to THREE. After long hours spent on looking for imaginary bugs I finally managed to get something that is actually working. Surprisingly, the most difficult part was to realize that the JSONLoader, or more precisely the Quaternion constructor, is in fact accepting quaternion coordinates in the form of (x,y,z,w), contrary to the Blender's (not only!) standard notation (w,x,y,z). Clearly, this seems to be a minor issue, but I think it at least deserves mentioning somewhere :) Quaternion.js is not an obvious place to look for a problem when your animation code does not work as expected, to be honest.
Also keep in mind, that the "Blender convention" is not at all accidental. In maths, one usually write a quaternion in the form:
q = w + i * x + j * y + z * k,
where i, j, k are some special constants, e.g. the unit quaternion is just q = 1 = 1 + i * 0 + j * 0 + k * 0. So the w-coordinate is evidently distinguished, and it feels more natural to write it on the first position. Similarly, the real part of a complex number always takes precedence over the imaginary part, and no one objects ;)
Cheers,
Tomasz
The text was updated successfully, but these errors were encountered: