當前位置: 首頁>>代碼示例>>C#>>正文


C# Quaternion.Conjugate方法代碼示例

本文整理匯總了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;
            }
        }
開發者ID:HowardIfeProjects,項目名稱:IsoPuzzle,代碼行數:37,代碼來源:QuaternionExt.cs


注:本文中的UnityEngine.Quaternion.Conjugate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。