【发布时间】:2019-09-08 08:51:41
【问题描述】:
我正在尝试基于沿指定四元数旋转的同一轴的四元数旋转分量,仅围绕一个轴(任何任意单位向量,不一定是 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);
}
我想复制上面的结果,但是对于任何给定的轴。
我已经深入谷歌试图找到这个问题的答案,但我还没有找到解决方案。任何帮助表示赞赏。
【问题讨论】:
-
请提供更多信息,说明您想如何使用它以及用于什么目的。目前这听起来有点像XY problem。为什么您明确需要
Quaternion作为输入?
标签: c# unity3d axis angle quaternions