Skip to content
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

glm::rotation() produce non-identity quaternions for equal vectors #234

Closed
WinterDog opened this issue Sep 3, 2014 · 2 comments
Closed

Comments

@WinterDog
Copy link

For equal or almost equal vectors (when cosTheta is ~= 1.0f) glm::rotation() can produce slightly incorrect quaternions. You can easily test it with this code:

glm::vec3 testVec = glm::normalize(glm::vec3(5.0f, 5.0f, 5.0f));
glm::quat rotQuat = glm::rotation(testVec, testVec); // Result will be (0.0f, 0.0f, 0.0f, 0.99999994f)

It is OK in most cases, but there are specific exceptions. I think it would be better to add check to glm::rotation() for such cases, something like that:

if (cosTheta >= static_cast<T>(1) - epsilon<T>())
    return quat();

This would also prevent unnecessary extra calculations like glm::cross() (which returns zero vector for that case).

@Groovounet
Copy link
Member

It looks like I missed that bug... sorry about that. It should be fixed in master branch for GLM 0.9.7.1 release.

Thanks,
Christophe

@OlivierSohn
Copy link

Hello, I think the fix was not correct, as it produced not an identity quaternion but a zero quaternion. #691 should fix it I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants