如何计算给定四元数旋转和指定轴的角度?
How to calculate the angle given a quaternion rotation and a specified axis?
我正在尝试根据沿指定四元数旋转的同一轴的四元数旋转分量,仅围绕一个轴(任意单位向量,不一定是 x、y 或 z)旋转对象。
public void Rotate(Quaternion rotation, Vector3 axis, Vector3 pointToRotateAround)
{
float angle = ?
gameObject.transform.RotateAround(pointToRotateAround, axis, angle);
}
我不知道如何获取我的四元数仅沿指定轴旋转的角度。我可以在轴为 y 时执行此操作,例如:
public void Rotate(Quaternion rotation, Vector3 pointToRotateAround)
{
gameObject.transform.RotateAround(pointToRotateAround, Vector3.up, rotation.eulerAngles.y);
}
我想复制上面的结果,但是对于任何给定的轴。
我已经深入 google 试图找到这个问题的答案,但我还没有找到解决方案。感谢任何帮助。
我解释你的问题的方式是,如果你有一组旋转点,它们将以什么角度绕其他轴移动。
唯一的问题是与不同轴的角度实际上取决于您正在查看的点。
但是,您可以尝试将旋转表示为轴角 (ω, θ)
,然后将点积与轴 v
相乘以获得新的角度 θ
按 w.v
缩放。这可能不是您想要的,但如果您添加详细信息以了解您想要实现的目标的更多详细信息,我们可能会更好地帮助您。
这是我想要的代码:
public void Rotate(Quaternion rotation, Vector3 axis, Vector3 pointToRotateAround)
{
float angle;
Vector3 rotAxis;
rotation.ToAngleAxis(out angle, out rotAxis);
float angleAroundAxis = Vector3.Dot(rotAxis, axis);
gameObject.transform.RotateAround(pointToRotateAround, axis, angleAroundAxis);
}
那么单位四元数(w,x,y,z)
的旋转角度也写成w+xi+yj+zk
是arccos(w)*2
.
如果角度>0,方向为(x,y,z)/sin( arccos(w)/2 )
否则没有具体方向,绕任意轴旋转恒等式; 0角度就是不旋转
我正在尝试根据沿指定四元数旋转的同一轴的四元数旋转分量,仅围绕一个轴(任意单位向量,不一定是 x、y 或 z)旋转对象。
public void Rotate(Quaternion rotation, Vector3 axis, Vector3 pointToRotateAround)
{
float angle = ?
gameObject.transform.RotateAround(pointToRotateAround, axis, angle);
}
我不知道如何获取我的四元数仅沿指定轴旋转的角度。我可以在轴为 y 时执行此操作,例如:
public void Rotate(Quaternion rotation, Vector3 pointToRotateAround)
{
gameObject.transform.RotateAround(pointToRotateAround, Vector3.up, rotation.eulerAngles.y);
}
我想复制上面的结果,但是对于任何给定的轴。
我已经深入 google 试图找到这个问题的答案,但我还没有找到解决方案。感谢任何帮助。
我解释你的问题的方式是,如果你有一组旋转点,它们将以什么角度绕其他轴移动。
唯一的问题是与不同轴的角度实际上取决于您正在查看的点。
但是,您可以尝试将旋转表示为轴角 (ω, θ)
,然后将点积与轴 v
相乘以获得新的角度 θ
按 w.v
缩放。这可能不是您想要的,但如果您添加详细信息以了解您想要实现的目标的更多详细信息,我们可能会更好地帮助您。
这是我想要的代码:
public void Rotate(Quaternion rotation, Vector3 axis, Vector3 pointToRotateAround)
{
float angle;
Vector3 rotAxis;
rotation.ToAngleAxis(out angle, out rotAxis);
float angleAroundAxis = Vector3.Dot(rotAxis, axis);
gameObject.transform.RotateAround(pointToRotateAround, axis, angleAroundAxis);
}
那么单位四元数(w,x,y,z)
的旋转角度也写成w+xi+yj+zk
是arccos(w)*2
.
如果角度>0,方向为(x,y,z)/sin( arccos(w)/2 )
否则没有具体方向,绕任意轴旋转恒等式; 0角度就是不旋转