three.js - 在 ThreeJS Object3D.applyMatrix4 中不连续
问题描述
我正在使用 Object3D.applyMatrix4 用矩阵转换一个对象,A
我发现在某一时刻它没有保留特征向量的方向。所以我尝试在身份矩阵之间
进行插值动画,我发现了这个:I
A
转型怎么可能不连续?
解决方案
Linear interpolation of rotation matrices isn't mathematically sound. The vectors composing a rotation matrix need to be unit length.. or at least stay a consistent length.
Imagine a clock with a hand at 12, and a hand at 6. If you Linearly interpolate the point at the tip of the 12 oclock hand, to the tip of the 6oclock hand, the point travels in a straight line from top of the clock to the bottom.
To interpolate the rotation represented by a 4x4 matrix, you can convert the rotations of the matrices, to quaternions, and .slerp (spherical linear interpolate) between those quaternions, then convert back to a matrix.
And then linearly interpolate the object.position. (although again.. this assumes linear motion between keyframes).
Now in the case that the rotation is small, you can get away with linearly interpolating the matrix, but you will need to orthonormalize it at each step, to reshape the mesh into one that has consistent length vectors that are orthogonal to each other. That isn't that hard.. you use a combination of dot products, multiplies and adds of the vectors forming the matrix rows (or columns, i forget) to orthonormalize the matrix. But its more of a pain, and less accurate than just using quaternions and .slerp.
推荐阅读
- javascript - 使用状态在 useffect 中不起作用并显示此错误
- c++ - 在撤消堆栈中中止撤消命令
- arrays - 从数组的某个部分减去一个数字
- reactjs - 反应路由器错误
- javascript - 在javascript中的字符串中查找多个(2)元素
- python - 如何在 qweb 报告上增加公司徽标图像大小
- firebase - 使用 Firebase 托管浏览网站
- javascript - d3.js:从同步刷选中获取数据
- javascript - 如何设置图像 src 的变量并在 javascript 函数中使用?
- mongodb - 是否有一种简单的方法可以为特定字段的每个唯一值选择最新文档?