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


C# Quaternion.Normalize方法代碼示例

本文整理匯總了C#中UnityEngine.Quaternion.Normalize方法的典型用法代碼示例。如果您正苦於以下問題:C# Quaternion.Normalize方法的具體用法?C# Quaternion.Normalize怎麽用?C# Quaternion.Normalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Quaternion的用法示例。


在下文中一共展示了Quaternion.Normalize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DecomposeSwingTwist

        /// <summary>
        /// Decomposes the quaterniong into a twist (around the axis) and a swing (rotation) around a vector perpendicular
        /// to the axis.
        /// 
        /// To rebuild, use:
        /// rThis = rSwing * rTwist
        /// 
        /// http://www.alinenormoyle.com/weblog/?p=726
        /// </summary>
        /// <param name="rThis"></param>
        /// <param name="rAxis"></param>
        /// <param name="rSwing"></param>
        /// <param name="rTwist"></param>
        public static void DecomposeSwingTwist(this Quaternion rThis, Vector3 rAxis, ref Quaternion rSwing, ref Quaternion rTwist)
        {
            Vector3 lTwistAxis = rAxis.normalized;

            // Dot(v, vTwist)
            float lDot = Vector3.Dot(new Vector3(rThis.x, rThis.y, rThis.z), lTwistAxis);

            // p = dot * vTwist
            lTwistAxis = lTwistAxis * lDot;

            // qTwist = (p, w)
            rTwist.x = lTwistAxis.x;
            rTwist.y = lTwistAxis.y;
            rTwist.z = lTwistAxis.z;
            rTwist.w = rThis.w;

            // qTwist.Normalize
            rTwist = rTwist.Normalize();

            rSwing = rThis * Quaternion.Inverse(rTwist);
        }
開發者ID:HowardIfeProjects,項目名稱:IsoPuzzle,代碼行數:34,代碼來源:QuaternionExt.cs


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