Пример #1
0
        /// <summary>
        /// Modeled after the piecewise exponentially-damped sine wave:
        /// y = (1/2)*sin(13pi/2*(2*x))*Math.Pow(2, 10 * ((2*x) - 1))      ; [0,0.5)
        /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
        /// </summary>
        public static float EaseInOutElastic(this float This)
        {
            if (This < 0.5f)
            {
                return(0.5f * Math.Sin(13 * HalfPi * (2 * This)) * Math.Pow(2, 10 * (2 * This - 1)));
            }

            return(0.5f * (Math.Sin(-13 * HalfPi * (2 * This - 1 + 1)) * Math.Pow(2, -10 * (2 * This - 1)) + 2));
        }
Пример #2
0
        /// <summary>
        /// Modeled after the piecewise exponentially-damped sine wave:
        /// y = (1/2)*sin(13pi/2*(2*x))*Math.Pow(2, 10 * ((2*x) - 1))      ; [0,0.5)
        /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
        /// </summary>
        public static float ElasticEaseInOut(float p)
        {
            if (p < 0.5f)
            {
                return(0.5f * Math.Sin(13 * HALFPI * (2 * p)) * Math.Pow(2, 10 * ((2 * p) - 1)));
            }

            return(0.5f * (Math.Sin(-13 * HALFPI * ((2 * p - 1) + 1)) * Math.Pow(2, -10 * (2 * p - 1)) + 2));
        }
Пример #3
0
 /// <summary>
 /// Modeled after the piecewise expoly-damped sine wave:
 /// y = (1/2)*sin(13pi/2*(2*x))*Math.Pow(2, 10 * ((2*x) - 1))      ; [0,0.5)
 /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
 /// </summary>
 internal static float EaseInOutElastic(float p)
 {
     if (p < 0.5f)
     {
         return(0.5f * Math.Sin(13 * HALFPI * (2 * p)) * Math.Pow(2, 10 * ((2 * p) - 1)));
     }
     else
     {
         return(0.5f * ((Math.Sin(-13 * HALFPI * (2 * p)) * Math.Pow(2, -10 * ((2 * p) - 1))) + 2));
     }
 }
Пример #4
0
        /// <summary>
        /// Modeled after the piecewise exponential
        /// y = (1/2)2^(10(2x - 1))         ; [0,0.5)
        /// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
        /// </summary>
        public static float EaseInOutExponential(this float This)
        {
            if (This.IsAlmostZero() || This.IsAlmostEqualTo(1f))
            {
                return(This);
            }

            if (This < 0.5f)
            {
                return(0.5f * Math.Pow(2, 20 * This - 10));
            }

            return(-0.5f * Math.Pow(2, -20 * This + 10) + 1);
        }
Пример #5
0
        /// <summary>
        /// Modeled after the piecewise exponential
        /// y = (1/2)2^(10(2x - 1))         ; [0,0.5)
        /// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
        /// </summary>
        public static float ExponentialEaseInOut(float p)
        {
            if (p == 0.0 || p == 1.0)
            {
                return(p);
            }

            if (p < 0.5f)
            {
                return(0.5f * Math.Pow(2, (20 * p) - 10));
            }

            return(-0.5f * Math.Pow(2, (-20 * p) + 10) + 1);
        }
Пример #6
0
        /// <summary>
        /// Modeled after the piecewise expo
        /// y = (1/2)2^(10(2x - 1))         ; [0,0.5)
        /// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
        /// </summary>
        internal static float EaseInOutExpo(float p)
        {
            if (p == 0.0 || p == 1.0)
            {
                return(p);
            }

            if (p < 0.5f)
            {
                return(0.5f * Math.Pow(2, (20 * p) - 10));
            }
            else
            {
                return((-0.5f * Math.Pow(2, (-20 * p) + 10)) + 1);
            }
        }
Пример #7
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*Math.Pow(2, -10x) + 1
 /// </summary>
 internal static float EaseOutElastic(float p)
 {
     return((Math.Sin(-13 * HALFPI * (p + 1)) * Math.Pow(2, -10 * p)) + 1);
 }
Пример #8
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(13pi/2*x)*Math.Pow(2, 10 * (x - 1))
 /// </summary>
 internal static float EaseInElastic(float p)
 {
     return(Math.Sin(13 * HALFPI * p) * Math.Pow(2, 10 * (p - 1)));
 }
Пример #9
0
 /// <summary>
 /// Modeled after the expo function y = -2^(-10x) + 1
 /// </summary>
 internal static float EaseOutExpo(float p)
 {
     return((p == 1.0f) ? p : 1 - Math.Pow(2, -10 * p));
 }
Пример #10
0
 /// <summary>
 /// Modeled after the exponential function y = 2^(10(x - 1))
 /// </summary>
 public static float EaseInExponential(this float This)
 {
     return(This.IsAlmostZero() ? This : Math.Pow(2, 10 * (This - 1)));
 }
Пример #11
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(13pi/2*x)*Math.Pow(2, 10 * (x - 1))
 /// </summary>
 public static float ElasticEaseIn(float p)
 {
     return(Math.Sin(13 * HalfPi * p) * Math.Pow(2, 10 * (p - 1)));
 }
Пример #12
0
 /// <summary>
 /// Modeled after the exponential function y = 2^(10(x - 1))
 /// </summary>
 public static float ExponentialEaseIn(float p)
 {
     return((p == 0.0f) ? p : Math.Pow(2, 10 * (p - 1)));
 }
Пример #13
0
 public static float ExpoIn(float p)
 {
     return(Mathf.Pow(2, (10 * (p - 1f))));
 }
Пример #14
0
 /// <summary>
 /// Modeled after the expo function y = -2^(-10x) + 1
 /// </summary>
 internal static float EaseOutExpo(float p) => (p == 1.0f) ? p : 1 - Math.Pow(2, -10 * p);
Пример #15
0
 /// <summary>
 /// Modeled after the expo function y = 2^(10(x - 1))
 /// </summary>
 internal static float EaseInExpo(float p) => (p == 0.0f) ? p : Math.Pow(2, 10 * (p - 1));
Пример #16
0
 /// <summary>
 /// Modeled after the exponential function y = -2^(-10x) + 1
 /// </summary>
 public static float EaseOutExponential(this float This)
 {
     return(This.IsAlmostEqualTo(1f) ? This : 1 - Math.Pow(2, -10 * This));
 }
Пример #17
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*Math.Pow(2, -10x) + 1
 /// </summary>
 public static float EaseOutElastic(this float This)
 {
     return(Math.Sin(-13 * HalfPi * (This + 1)) * Math.Pow(2, -10 * This) + 1);
 }
Пример #18
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(13pi/2*x)*Math.Pow(2, 10 * (x - 1))
 /// </summary>
 public static float EaseInElastic(this float This)
 {
     return(Math.Sin(13 * HalfPi * This) * Math.Pow(2, 10 * (This - 1)));
 }
Пример #19
0
 public static float ElasticIn(float p)
 {
     return(-(Mathf.Pow(2, 10 * (p - 1f)) * Mathf.Sin((p - 1.075f) * (Mathf.PI * 2) / 0.3f)));
 }
Пример #20
0
        // 没有处理在内部的情况
        public static bool Intersect(CylinderXCollider src, CylinderXCollider dst, out XContact?contact)
        {
            var     space    = src.Radius + dst.Radius;
            var     sqrSpace = space * space;
            Vector3 n        = Vector3.zero;

            n.x = dst.Position.x - src.Position.x;
            n.z = dst.Position.z - src.Position.z;
            if (n.sqrMagnitude > sqrSpace)
            {
                contact = null;
                return(false);
            }

            var halfHa  = src.Height * 0.5f;
            var topA    = src.Position.y + halfHa;
            var bottomA = src.Position.y - halfHa;
            var halfHb  = dst.Height * 0.5f;
            var topB    = dst.Position.y + halfHb;
            var bottomB = dst.Position.y - halfHb;

            Vector3 normal;
            float   penetration;

            if (Mathf.Sign(topA - topB) == Mathf.Sign(bottomB - bottomA))
            {
                // 水平相撞
                normal      = n.normalized;
                penetration = space - n.magnitude;
            }
            else if (n.sqrMagnitude < Mathf.Pow(dst.Radius - src.Radius, 2f))
            {
                // 垂直相撞
                if (dst.Position.y > src.Position.y)
                {
                    normal      = Vector3.up;
                    penetration = topA - bottomB;
                }
                else
                {
                    normal      = Vector3.down;
                    penetration = topB - bottomA;
                }
            }
            else
            {
                var   horizontalP = space - n.magnitude;
                float verticalP;
                // 斜向相撞
                if (topB > topA)
                {
                    verticalP = topA - bottomB;
                }
                else
                {
                    verticalP = topB - bottomA;
                }

                if (horizontalP < verticalP)
                {
                    normal      = n.normalized;
                    penetration = horizontalP;
                }
                else
                {
                    normal      = topB > topA ? Vector3.up : Vector3.down;
                    penetration = verticalP;
                }
            }
            if (normal == Vector3.zero)
            {
                normal = Vector3.up;
            }
            contact = new XContact(src, dst, normal, penetration);
            return(true);
        }
Пример #21
0
 /// <summary>
 /// Modeled after the exponential function y = -2^(-10x) + 1
 /// </summary>
 public static float ExponentialEaseOut(float p)
 {
     return((p == 1.0f) ? p : 1 - Math.Pow(2, -10 * p));
 }
Пример #22
0
 /// <summary>
 /// Modeled after the expo function y = 2^(10(x - 1))
 /// </summary>
 internal static float EaseInExpo(float p)
 {
     return((p == 0.0f) ? p : Math.Pow(2, 10 * (p - 1)));
 }
Пример #23
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*Math.Pow(2, -10x) + 1
 /// </summary>
 public static float ElasticEaseOut(float p)
 {
     return(Math.Sin(-13 * HalfPi * (p + 1)) * Math.Pow(2, -10 * p) + 1);
 }
Пример #24
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*Math.Pow(2, -10x) + 1
 /// </summary>
 static internal float easeOutElastic(float p)
 {
     return(Math.Sin(-13 * HALFPI * (p + 1)) * Math.Pow(2, -10 * p) + 1);
 }