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::to_string on quaternions writes components in the wrong order #681

Closed
zoopp opened this issue Sep 13, 2017 · 1 comment
Closed

glm::to_string on quaternions writes components in the wrong order #681

zoopp opened this issue Sep 13, 2017 · 1 comment
Assignees
Milestone

Comments

@zoopp
Copy link

zoopp commented Sep 13, 2017

I was debugging an issue in my code and I had to visually inspect the value of a quaternion so I turned to glm::to_string to provide me with a textual representation. Without even thinking about it, I was expecting the output to be in {w, x, y, z} order because that's how I've seen it presented in online resources that I've been learning from. Unfortunately, that was not the case as the order in which the output is written is {x, y, z, w}.

This hasn't affected me much but I did lose some time because of it and I don't think this is intended behaviour.

Sample code to reproduce the issue:

#include <iostream>

#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/string_cast.hpp>

int main() {
    auto a = glm::quat{1.0f, {2.0f, 3.0f, 4.0f}};
    std::cout << "Version: " << GLM_VERSION << '\n'
              << glm::to_string(a) << "\n"
              << "a{w, x, y, z} = "
              << "{" << a.w << ", " << a.x << ", " << a.y << ", " << a.z << "}\n";
    return 0;
}

Sample output:

Version: 98
quat(2.000000, 3.000000, 4.000000, 1.000000)
a{w, x, y, z} = {1, 2, 3, 4}

I've looked around in the code and I see that this is a trivial fix. I can submit a pull request if this should be addressed.

@Groovounet
Copy link
Member

This issue is fixed in master branch for GLM 0.9.9 release.

Thanks for contributing,
Christophe

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

2 participants