-
Notifications
You must be signed in to change notification settings - Fork 21
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
Return quaternion as [x,y,z,w] #29
Comments
@alexshalamov @anssiko @kenchris thoughts? |
sounds like a good idea. |
I think it makes a lot of sense. Also in math quaternions are normally represented using i, j and k components, so order doesn't matter, in mathematical sense. If we define just the values (ie no i, j and k), ie. x + yi +zj + wk, the order [x, y, z, w] makes a lot of sense. The following are valid quaternions: 1 Like complex numbers they i^2 == -1 :-) and so it j^2 == -1 and k^== -1 and ijk == -1 |
in each of your examples the real component stays first and that's the standard representation :) |
Yes, I assume that x is used for representing the real component, right? |
no, |
Oh, not obvious :-) so is that also the case for the other implementations? Maybe we should add a note explaining this I guess it makes sense when you talk about scalar and vector part. But this definitely needs a note and we need to make sure that w is really the scalar part in the other APIs |
For both math and alphabetical reasons the current order [w,x,y,z] is correct, however for some reason JS frameworks prefer [x,y,z,w] , so this issue is more about API convenience.. |
Could you give more details, what such note should contain? |
Sure, say how quaternions are represented, ie w + xi + yj + zk, with a scalar w and a vector x, y, z. And then mention that we expose these as vector + scalar, [x, y, z, w] as that is the most prevalent way of doing that when exposed as an array, but that other libraries etc could impose a different order like [w, x, y, z] |
Reopen to add an explaining note |
Even though a standard form of quaternion representation in math is starting from the real part (i.e. [w,x,y,z]) many of popular WebGL frameworks [1][2][3][4] use a different order of [x,y,z,w]. We probably should be compatible and should update the spec accordingly.
[1] https://doc.babylonjs.com/classes/2.4/quaternion
[2] https://threejs.org/docs/api/math/Quaternion.html
[3] https://www.blend4web.com/api_doc/module-quat.html#.fromValues
[4] http://developer.playcanvas.com/en/api/pc.Quat.html
The text was updated successfully, but these errors were encountered: