本文整理汇总了C#中UnityEngine.Quaternion.Conjugate方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.Conjugate方法的具体用法?C# Quaternion.Conjugate怎么用?C# Quaternion.Conjugate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Quaternion
的用法示例。
在下文中一共展示了Quaternion.Conjugate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecomposeTwistSwingAxisAngles
/// <summary>
/// Extracts out the rotational axis and angles for a swing and twist. Note that this function expects the
/// bone to be oriented along the 'Y' axis.
/// </summary>
/// <param name="rThis"></param>
/// <param name="rTwistAxis"></param>
/// <param name="rTwistAngle"></param>
/// <param name="rSwingAxis"></param>
/// <param name="rSwingAngle"></param>
public static void DecomposeTwistSwingAxisAngles(this Quaternion rThis, Vector3 rTwistAxis, ref float rTwistAngle, ref Vector3 rSwingAxis, ref float rSwingAngle)
{
rTwistAngle = 2.0f * Mathf.Atan2(rThis.y, rThis.w) * Mathf.Rad2Deg;
Vector4 lComponents = new Vector4(0, rThis.y, 0, rThis.w) / Mathf.Sqrt(rThis.y * rThis.y + rThis.w * rThis.w);
Quaternion lTwist = new Quaternion(lComponents.x, lComponents.y, lComponents.z, lComponents.w);
Quaternion lSwing = rThis * lTwist.Conjugate();
float lLength = Mathf.Sqrt(lSwing.x * lSwing.x + lSwing.y * lSwing.y + lSwing.z * lSwing.z);
if (lLength > 0.000001f)
{
float lInvLength = 1.0f / lLength;
rSwingAxis.x = lSwing.x * lInvLength;
rSwingAxis.y = lSwing.y * lInvLength;
rSwingAxis.z = lSwing.z * lInvLength;
if (lSwing.w < 0.0f)
rSwingAngle = 2.0f * Mathf.Atan2(-lLength, -lSwing.w) * Mathf.Rad2Deg; //-PI,0
else
rSwingAngle = 2.0f * Mathf.Atan2(lLength, lSwing.w) * Mathf.Rad2Deg; //0,PI
}
else
{
rSwingAxis = Vector3.right;
rSwingAngle = 0.0f;
}
}