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
vec4 to quat conversion #179
Comments
Hey there (: I'm not exactly sure what behavior you would expect. I'm guessing what you would expect is the following: # given x, y, z and w are some numbers
vec = glm.vec4(x, y, z, w)
qua = glm.quat(*vec)
assert qua.x == x
assert qua.y == y
assert qua.z == z
assert qua.w == w That is not the case however, because Taking that into account, you can happily convert between >>> q = glm.quat(1, 2,3,4)
>>> q
quat( 1, 2, 3, 4 )
>>> v = glm.vec4(*q)
>>> v
vec4( 1, 2, 3, 4 )
>>> glm.quat(*v)
quat( 1, 2, 3, 4 ) Though it appears that this is not the behavior you need. Thank you very much! Cheers |
My use case involves compressing and decompressing quaternions. my quaternion value is the result of vec3 and vec4 operations and right now i have to cast the vec4 to quat with I think it would make sens to support I am not expecting the following to work. # given x, y, z and w are some numbers
vec = glm.vec4(x, y, z, w)
qua = glm.quat(*vec)
assert qua.x == x
assert qua.y == y
assert qua.z == z
assert qua.w == w i know the "bad" quaternion parameter order is there in glm too and it should not be changed. |
Yeah, that's sort of what I expected. About the code snippet, I think I messed up explaining what I wanted to know. Okay, so I'm not sure about using the constructor Thanks for your input! |
an explicit function call instead of the ambiguous constructor call would be a great idea. i expect the |
This PR should do the trick (: I'm a little busy at the moment so I couldn't really do much testing. I believe this works as intended though. |
I get back with testing results :) thank you very much |
Visually the result seems to be correct. However I have noticed a small bug with the memory layout of quat when converted to bytes: The memory layout is For now i can use another |
Need to add documentation and need to check the possible bug |
Type stubs for the new functions are also missing. |
Hi,
I was wondering how to convert vec4 to quat using PyGLM.
The quat constructor does not accept vec4 instances so I tried:
the example above obviously producing a bad result due to the quat constructor.
is there a solution to convert quat to vec4 and vec4 to quat using PyGLM?
if not I can make a PR extending the constructor logic. would that be welcome?
thank you
The text was updated successfully, but these errors were encountered: