zoukankan      html  css  js  c++  java
  • Transform using the glm library

    // Rotation
    
    /* Matrix to quaternion */
        glm::quat q_from_matrix3x3{ glm::mat3{1} }; // cast operator will handle this
    
        glm::quat q_from_matrix4x4{ glm::mat4{1} }; // cast operator will handle this
    
    /* Matrix to Euler rotation */
        float x, y, z; // radians
        glm::extractEulerAngleXYZ(glm::mat4{ 1 }, x, y, z);
    
        glm::extractEulerAngleZYX(glm::mat4{ 1 }, z, y, x); // pay attention to the parameter order, z->y->x
    
    /* Quaternion to matrix */
        glm::mat3 matrix3x3_from_quaternion{ glm::quat{1.0f, 0, 0, 0} }; // cast operator will handle this
    
        glm::mat4 matrix4x4_from_quaternion{ glm::quat{1.0f, 0, 0, 0} }; // cast operator will handle this
    
    /* Quaternion to Euler rotation */
        glm::vec3 euler_angles_zyx = glm::eulerAngles(glm::quat{ 1.0f, 0, 0, 0 }); // rotation matrices do not commute in multiplication, and the rotation around x->y->z order means z->y->x matrices order
    
    /* Euler rotation to matrix */
        glm::mat3 matrix3x3_from_euler = glm::eulerAngleXYZ(0.0f, 0.0f, 0.0f); // rotation order is z axis -> y axis -> x axis, the equal matirces multiplication order is x->y->z
    
        glm::mat3 matrix4x4_from_euler = glm::eulerAngleZYX(0.0f, 0.0f, 0.0f); // rotation order is x axis -> y axis -> z axis, the equal matirces multiplication order is z->y->x
    
    /* Euler rotation to quaternion */
        float euler_x, euler_y, euler_z; // radians
        euler_x = euler_y = euler_z = 0.0f;
        glm::quat quaternion_from_euler{ glm::vec3{euler_x, euler_y, euler_z} }; // the original rotation order is x axis ->  y axis -> z axis, matrices multip
  • 相关阅读:
    FMDB线程安全
    FMDB的使用
    iOS【手机验证码】判断手机号是否合法
    UIScrollView UIScrollViewDelegate
    iOS苹果开发者常用网站
    < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />
    CSS布局口诀
    css垂直居中
    在js中使用createElement创建HTML对象和元素
    jQuery-对Radio/CheckBox的操作集合
  • 原文地址:https://www.cnblogs.com/wangpei0522/p/12894752.html
Copyright © 2011-2022 走看看