示例#1
0
        /// <summary>
        /// 進行度合から移行度合を取得
        /// </summary>
        /// <param name="Progress">進行度合</param>
        /// <returns>移行度合</returns>
        public float Evaluate(float Progress)
        {
            //ニュートン法による近似
            float t = CGHelper.Clamp(Progress, 0, 1);
            float dt;

            do
            {
                dt = -(fx(t) - Progress) / dfx(t);
                if (float.IsNaN(dt))
                {
                    break;
                }
                t += CGHelper.Clamp(dt, -1f, 1f);  //大幅に移動して別の解に到達するのを防止する用
            } while (Math.Abs(dt) > Epsilon);
            return(CGHelper.Clamp(fy(t), 0f, 1f)); //念のため、0-1の間に収まるようにした
        }
示例#2
0
        /// <summary>
        /// Advanced degree from a transition degree
        /// </summary>
        /// <param name="Progress">Advanced degree</param>
        /// <returns>Transition degree</returns>
        public float Evaluate(float Progress)
        {
            //Newton method approximation
            float t = CGHelper.Clamp(Progress, 0, 1);
            float dt;

            do
            {
                dt = -(fx(t) - Progress) / dfx(t);
                if (float.IsNaN(dt))
                {
                    break;
                }
                t += CGHelper.Clamp(dt, -1f, 1f);  //To prevent moving dramatically, reaching a different solution for
            } while (Math.Abs(dt) > Epsilon);
            return(CGHelper.Clamp(fy(t), 0f, 1f)); //Just in case the fit between 0-1.
        }