Пример #1
0
        public static Vector3 Slerp(Vector3 from, Vector3 to, float step)
        {
            if (FezMath.AlmostEqual(step, 0.0f))
            {
                return(from);
            }
            if (FezMath.AlmostEqual(step, 1f))
            {
                return(to);
            }
            float num1 = Vector3.Dot(from, to);

            if ((double)num1 == -1.0)
            {
                Vector3 vector3 = Vector3.Cross(Vector3.Normalize(to - from), Vector3.UnitY);
                if ((double)step < 0.5)
                {
                    return(FezMath.Slerp(from, vector3, step * 2f));
                }
                else
                {
                    return(FezMath.Slerp(vector3, to, (float)(((double)step - 0.5) / 2.0)));
                }
            }
            else
            {
                double a = Math.Acos((double)MathHelper.Clamp(num1, -1f, 1f));
                if (FezMath.AlmostEqual(a, 0.0))
                {
                    return(to);
                }
                double num2 = Math.Sin(a);
                return((float)(Math.Sin((1.0 - (double)step) * a) / num2) * from + (float)(Math.Sin((double)step * a) / num2) * to);
            }
        }
Пример #2
0
 protected override void Interpolate(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
 {
     if (SplineInterpolation <Vector3> .LongScreenshot)
     {
         this.Current = FezMath.Slerp(p1, p2, t);
     }
     else
     {
         this.Current = Vector3.CatmullRom(p0, p1, p2, p3, t);
     }
 }
Пример #3
0
        public static float CurveAngle(float from, float to, float step)
        {
            if (FezMath.AlmostEqual(step, 0.0f))
            {
                return(from);
            }
            if (FezMath.AlmostEqual(from, to) || FezMath.AlmostEqual(step, 1f))
            {
                return(to);
            }
            Vector2 vector2 = FezMath.Slerp(new Vector2((float)Math.Cos((double)from), (float)Math.Sin((double)from)), new Vector2((float)Math.Cos((double)to), (float)Math.Sin((double)to)), step);

            return((float)Math.Atan2((double)vector2.Y, (double)vector2.X));
        }