How to convert glm::quat data to glm::vec3 angles?
Example: I've start data:
glm::vec3 start = glm::vec3(90, 30, 45);
and after convert to quat
(0,730946)(0,016590)(0,677650)
.... How to convert quat to glm::vec3(90, 30, 45) ??? And get initial data (90, 30, 45)
Use the built-in glm::eulerAngles()
function and then convert the resulting radians back to degrees.
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/euler_angles.hpp> // glm::eulerAngles()
int main()
{
glm::vec3 startDegrees = glm::vec3(90.0f, 30.0f, 45.0f);
glm::vec3 startRadians = glm::radians(startDegrees);
glm::quat q = glm::quat(startRadians);
glm::vec3 eulerRads = glm::eulerAngles(q);
glm::vec3 eulerDegs = glm::degrees(eulerRads);
return 0;
}