gpt4 book ai didi

matrix - glm - 将 mat4 分解为平移和旋转?

转载 作者:行者123 更新时间:2023-12-03 12:23:48 26 4
gpt4 key购买 nike

出于 lerping 的目的,我需要将 4x4 矩阵分解为四元数和 vec3。
获取四元数很简单,因为您可以将矩阵传递给构造函数,但我找不到获取翻译的方法。
一定有办法吗?

最佳答案

看起来 glm 0.9.6 支持矩阵分解
http://glm.g-truc.net/0.9.6/api/a00204.html

#include <glm/gtx/matrix_decompose.hpp>

glm::mat4 transformation; // your transformation matrix.
glm::vec3 scale;
glm::quat rotation;
glm::vec3 translation;
glm::vec3 skew;
glm::vec4 perspective;
glm::decompose(transformation, scale, rotation, translation, skew, perspective);

关于matrix - glm - 将 mat4 分解为平移和旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17918033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com