有没有像subVectors()这样的方法,但适用于四元数?

huangapple go评论61阅读模式
英文:

Is there a method like subVectors() but for Quaternions?

问题

我曾经使用getWorldRotation()与我的Vector3,但由于getWorldRotation()似乎已经不存在,我现在尝试使用getWorldQuaternion()。但现在我遇到另一个问题,因为之前我使用了subVectors(),如果我要切换到Quaternions,就不能这样做了。是否有类似于subVectors()的内置方法适用于Quaternions?

查看了Three.js文档一会儿,但找不到它。

英文:

I used to use getWorldRotation() with my Vector3 but since getWorldRotation() seems to be gone I am trying to use getWorldQuaternion(). But now I have another problem since before I used subVectors() and now can't do that if I'm having to switch to Quaternions. Is there any built in method like subVectors() for Quaternions?

Looked at Threejs docs for a bit but could't find it.

答案1

得分: 0

如果要结合两个四元数旋转效果,您应该将它们相乘,而不是相加。同样,如果要减去一个四元数,应该将其与其逆四元数相乘。

quatResult = new THREE.Quaternion().multiplyQuaternions(quaternion1, quaternion2.invert())

参考链接

英文:

If you want to combine the effect of two quaternion rotations, you multiply them, not add them. Similarly, If you want to subtract multiply it with its inverse.
Ref

quatResult = new THREE.Quaternion().multiplyQuaternions(quaternion1, quaternion2.invert())

答案2

得分: 0

getWorldRotation() 得到了欧拉角,对吧?
这将为您获取欧拉角(我希望):

let quaternion, rotation;
object3d.getWorldQuaternion(quaternion);
rotation = new THREE.Euler().setFromQuaternion( quaternion, eulerOrder );
英文:

getWorldRotation() got you the Euler angles, didn't it?
This will get you the Euler angles (I hope):

let quaternion, rotation;
object3d.getWorldQuaternion(quaternion);
rotation = new THREE.Euler().setFromQuaternion( quaternion, eulerOrder );

huangapple
  • 本文由 发表于 2023年5月25日 20:22:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76332227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定