-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Issue in quaternion log function #199
Comments
I shall add that after the following code : |
Erm, yes that code seems wrong. I have fixed the parameter inversion. The glm::log function returns a quaternion that is quite a NaN for the quaternion I think which explain the glm::exp behavior on that result. This said log(0) is -inf so the result you see might actually make sense here. |
Thanks for taking in account the bug described in my first message. "This said log(0) is -inf so the result you see might actually make sense here." Sorry, but I think you misunderstood the problem in my second message. The exp function is the one producing NaNs : |
Erm true. I understood correctly your explanation but my analysis was too quick. |
Good. I hope this can benefit others, though I'm guessing not much people use log and exp for quaternions. |
Another problem with quaternion log : Problem is (it just happened to me with Visual Studio 2012), Vec3Len can compute to a strict 0, even if q.x, q.y and q.z aren't all strict 0s. Thus raising division by zero. I fixed it this way (I realize it may be a waste to compute Vec3Len in all cases, but I am more concerned with consistency) : Please let me know if you think I disregarded something. |
I think you can remove the |
Good point lol ! |
Do you have a fix for this log function? If yes, a pull request would be appreciated. :D |
Sorry, I'm afraid I don't understand what you're asking for :-s |
If you want the log function for quaternion to be fix in GLM, it would be better to submit an implementation. |
Sorry, I'm not used to GitHub or collaborative coding in general. I thought submitting my modification in this discussion was enough. What am I supposed to do ? |
glm [at] g-truc.net would do then, thanks! |
I have applied your changes in GLM 0.9.5 branch and they will be included in GLM 0.9.5.4 release. Thanks for contributing! |
In GLM version 0.9.5.3, in the quaternion log function, there is a return line as follows :
return detail::tquat<T, P>(t * q.x, t * q.y, t * q.z, log(QuatLen));
where I guess it should obviously be
return detail::tquat<T, P>(log(QuatLen), t * q.x, t * q.y, t * q.z);
as the quaternion constructor asks for (w,x,y,z) in that order.
I must say I only realized the prototype then, as it doesn't seem at all straightforward to me. I would have expected it to use order (x,y,z,w). I guess the person who wrote the log function made the same mistake.
The text was updated successfully, but these errors were encountered: