There's no easy way of getting an identity for quaternions
In the experimental headers, there's a function
As quad_identity accepts no function arguments, you have to pass the template arguments T and Q explicitely resulting in calls like
glm::quat_identity<glm::quat::value_type, glm::highp>()
which in my opinion reveals more knowledge of glm implementation details than necessary.
My personal preference
My personally prefered would be to return to the old way of calling
or something comparable like using static class functions for easy initialization in general:
glm::quat::identitfy()
glm::vec3::x_axis() // Returns glm::vec3(1, 0, 0)
But for some reason, this was removed, so I assume that's not an option. So here are two other suggestions:
Alternative suggestion1: initialization template class
A template class providing static functions with interesting values.
Something comparable to std::numeric_limits ;)
This would make typical values quickly accessible
glm::init<glm::quat>::identity()
glm::init<glm::vec3>::x_axis() // Returns glm::vec3(1, 0, 0)
Here the user has to provide only the quat type he wants to use as template argument
Alternative suggestion 2:
A function only accepting the whole quat type as only argument
template<typename quat_type>
inline quat_type quat_identity()
{
quat_type q;
q.x = q.y = q.z = typename quat_type::value_type(0);
q.w = typename quat_type::value_type(1);
return q;
}
This implemetation could be used like this:
glm::quat_identity<glm::quat>()
Here the user also has to provide only the quat type he wants to use as template argument
There's no easy way of getting an identity for quaternions
In the experimental headers, there's a function
As
quad_identityaccepts no function arguments, you have to pass the template argumentsTandQexplicitely resulting in calls likewhich in my opinion reveals more knowledge of glm implementation details than necessary.
My personal preference
My personally prefered would be to return to the old way of calling
or something comparable like using static class functions for easy initialization in general:
But for some reason, this was removed, so I assume that's not an option. So here are two other suggestions:
Alternative suggestion1: initialization template class
A template class providing static functions with interesting values.
Something comparable to
std::numeric_limits;)This would make typical values quickly accessible
Here the user has to provide only the quat type he wants to use as template argument
Alternative suggestion 2:
A function only accepting the whole quat type as only argument
This implemetation could be used like this:
Here the user also has to provide only the quat type he wants to use as template argument