This is really frustrating. Various maths libs use different conventions, but GLM seems to be inconsistent even internally (at least as of early 2018).
The constructor glm::quat(...)
is w, x, y, z:
quaternion.hpp:
GLM_FUNC_DECL GLM_CONSTEXPR tquat(T w, T x, T y, T z);
* beware empty constructors no longer initialize to the identity. See GLM_FORCE_CTOR_INIT
. Could add to CFLAGS.
The internal order is x, y, z, w:
quaternion.hpp:
struct { T x, y, z, w;};
Using glm::make_quat
simply does a memcpy, which is x, y, z, w:
type_ptr.inl:
memcpy(value_ptr(Result), ptr, sizeof(tquat<T, defaultp>));
Using glm::string_cast
gives w, x, y, z:
string_cast.inl:
return detail::format(FormatStr.c_str(),
static_cast<typename cast<T>::value_type>(x[3]),
static_cast<typename cast<T>::value_type>(x[0]),
static_cast<typename cast<T>::value_type>(x[1]),
static_cast<typename cast<T>::value_type>(x[2]));
Note: The [] operator is return (&x)[i];
(which assumes x is first)