gpt4 book ai didi

rotation - 四元数绕轴旋转的分量

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

我无法找到有关此主题的任何有用信息。基本上我想找到四元数旋转的分量,即围绕给定轴(不一定是 X、Y 或 Z - 任何任意单位向量)。有点像将四元数投影到向量上。因此,如果我要求围绕与四元数轴平行的某个轴旋转,我会得到相同的四元数。如果我要求绕与四元数轴正交的轴旋转,我会得到一个恒等四元数。介于两者之间......好吧,这就是我想知道如何解决的:)

最佳答案

这个问题有一个优雅的解决方案,特别适合四元数。它被称为“摆动扭曲分解”:

伪代码

/**
Decompose the rotation on to 2 parts.
1. Twist - rotation around the "direction" vector
2. Swing - rotation around axis that is perpendicular to "direction" vector
The rotation can be composed back by
rotation = swing * twist

has singularity in case of swing_rotation close to 180 degrees rotation.
if the input quaternion is of non-unit length, the outputs are non-unit as well
otherwise, outputs are both unit
*/
inline void swing_twist_decomposition( const xxquaternion& rotation,
const vector3& direction,
xxquaternion& swing,
xxquaternion& twist)
{
vector3 ra( rotation.x, rotation.y, rotation.z ); // rotation axis
vector3 p = projection( ra, direction ); // return projection v1 on to v2 (parallel component)
twist.set( p.x, p.y, p.z, rotation.w );
twist.normalize();
swing = rotation * twist.conjugated();
}

这段代码的长答案和推导可以在这里找到 http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition/

关于rotation - 四元数绕轴旋转的分量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3684269/

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