首页 > 解决方案 > 在 ThreeJS Object3D.applyMatrix4 中不连续

问题描述

我正在使用 Object3D.applyMatrix4 用矩阵转换一个对象,A我发现在某一时刻它没有保留特征向量的方向。所以我尝试在身份矩阵之间
进行插值动画,我发现了这个:IA

在此处输入图像描述

转型怎么可能不连续?

标签: three.js3dlinear-algebraeigenvalueeigenvector

解决方案


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.


推荐阅读